'RewriteCond for specific folder
I would like to do the following:
I have a htaccess file that makes every request go trough index.php. If I am not mistaken this is called bootstrapping? (I haven't done this before).
I would like to make a subdirectory in the root directory of the site that will serve as a "test" site because I cannot add a subdomain. I need a htaccess rewritecond that will redirect any request under the teszt folder to the index.php in the same folder.
So if I enter example.com/[anything] I get data sent to the index.php in the root and if I enter example.com/teszt/[anything], the data needs to be sent to teszt/index.php
This is my htaccess file:
IndexIgnore *
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Solution 1:[1]
You can use these rules in htaccess in your root folder :
RewriteEngine On
#rewrite /subfolder/foobar to /subfolder/index.php
ReweriteRule !subfolder/index\.php /subfolder/index.php [L]
#rewrite /foobar to /index.php
RewriteRule !index\.php /index.php [L]
The rules above also rewrites your existent files to index.php . If you do not want to rewrite your files , just add a condition to the rule RewriteCond %{REQUEST_FILENAME} !-f .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amit Verma |
