htaccess-仅在文件夹内重写 [英] htaccess - rewrite only inside folder
问题描述
我有一个文件夹-职业-我只想对该文件夹的文件进行重写,例如:
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->不在文件夹中
mydomain.com/file.html -> its out of the folder
mydomain.com/folerone/file.html->不在文件夹中
mydomain.com/folerone/file.html -> its out of the folder
mydomain.com/careers/->这将调用文件index.php
mydomain.com/careers/ -> this calls the file index.php
mydomain.com/careers/item->这将使用$ _GET变量item调用文件index.php
mydomain.com/careers/item -> this calls the file index.php with the $_GET variable item
mydomain.com/careers/item2->这将使用$ _GET变量item2调用文件index.php
mydomain.com/careers/item2 -> this calls the file index.php with the $_GET variable item2
我实际的.htaccess是:
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?
推荐答案
将.htaccess文件放入careers文件夹
put the .htaccess file inside the careers folder
RewriteRule item([0-9]*)?$ index.php?itemid=item$1 [QSA]
这篇关于htaccess-仅在文件夹内重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!