I have a .htaccess
file that adds PATH_INFO
in the index.php
file (to the routing system):
RewriteEngine On
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(?!index\.php(/.*|$))([a-zA-Z0-9\-\/.]+)$ index\.php/$1 [QSA,L]
This works perfectly with my route system that is in index.php
The problem is that I want to use 3rd party softwares (3rdparty) at the same time as the routing system, so I did this in .htaccess :
RewriteEngine On
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(?!3rdparty/.*|index\.php(/.*|$))(.*)$ 3rdparty/$1 [QSA,L]
This RewriteRule tries to access files that are in the "3rdparty" folder rewriting to not present the 3rdparty
in the url, but if the file or folder does not exist within 3rdparty then the system should use the routes. >
Example, if you access http://localhost/folder1/
will show the contents of the /var/www/3rdparty/folder1/
file, but if the file does not exist in the 3rdparty
folder then you should use the route system.
Folder structure
This is just an example
project
├── index.php
├── .htaccess
└── 3rdparty
├── folder1
└── folder2
├── file1.html
└── file2.html
What I want is to access other PHP files without typing something like http://localhost/3rdparty/something...
Examples (see folder structure above):
-
http://example/project/folder1
will display the content ofhttp://example/project/3rdparty/folder1
-
http://example/project/folder2
will display the content ofhttp://example/project/3rdparty/folder2/
-
http://example/project/folder2/file1.html
will display the content ofhttp://example/project/3rdparty/folder2/file1.html
-
http://example/project/folder2/file2.html
will display the content ofhttp://example/project/3rdparty/folder2/file2.html
-
http://example/project/folder3/file3.html
(url not in the 3rdparty folder) will show the contents ofhttp://example/project/index.php/folder3/file3.html
How can I do this?