问题
I hava a folder - careers - and i want to do the rewrite only for the files of that folder, for example:
mydomain.com/file.html -> its out of the folder
mydomain.com/folerone/file.html -> its out of the folder
mydomain.com/careers/ -> this calls the file index.php
mydomain.com/careers/item -> this calls the file index.php with the $_GET variable item
mydomain.com/careers/item2 -> this calls the file index.php with the $_GET variable item2
My actual .htaccess is:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/]+) index.php?itemid=$1 [QSA]
This is not working.. can someone help?
回答1:
put the .htaccess file inside the careers folder
RewriteRule item([0-9]*)?$ index.php?itemid=item$1 [QSA]
来源:https://stackoverflow.com/questions/23138555/htaccess-rewrite-only-inside-folder