htaccess - rewrite only inside folder

妖精的绣舞 提交于 2019-12-24 07:06:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!