The answers present in Redirect requests only if the file is not found? don't solve to the specific situation, for a defined real path and are routes (which will use
PATH_INFO
).
I have a .htaccess
to add path_info
in the index.php
file:
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 the index.php
But I want use 3rdparty at the time, I used the following code:
RewriteEngine On
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(?!(3rdparty|index\.php)/.*)(.*)$ 3rdparty/$2 [QSA,L]
The idea of this code is that any file or folder inside the "3rdparty" override the routes, eg. If acess http://localhost/folder1/
it will show the contents of the file /var/www/3rdparty/folder1/
but if the file don't exists in 3rdparty
folder, then it will use the system routes.
Folder structure
This is an example of structure:
project
├── index.php
├── .htaccess
└── 3rdparty
├── folder1
└── folder2
├── file1.html
└── file2.html
I want to use other PHP files without having to access an address as http://localhost/3rdparty/something...
Examples (see folder structure):
http://example/project/folder1
shows contents from this addresshttp://example/project/3rdparty/folder1
http://example/project/folder2
shows contents from this addresshttp://example/project/3rdparty/folder2/
http://example/project/folder2/file1.html
shows contents from this addresshttp://example/project/3rdparty/folder2/file1.html
http://example/project/folder2/file2.html
shows contents from this addresshttp://example/project/3rdparty/folder2/file2.html
http://example/project/folder3/file3.html
(no-existing file in 3rdparty) shows contents from this addresshttp://example/project/index.php/folder3/file3.html
The problem is that I'm not able to use both at the same time, how can I do this?