htaccess-仅在文件夹内重写 [英] htaccess - rewrite only inside folder

查看:48
本文介绍了htaccess-仅在文件夹内重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件夹-职业-我只想对该文件夹的文件进行重写,例如:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆