使用htaccess删除文件夹名称

时间:2016-10-08 10:23:46

标签: php .htaccess

我的项目是核心PHP,其中包含一些包含views文件夹的文件夹结构,但我不想显示它,所以我在htaccess中尝试了很多但没有成功

我想要网址结构

http://domain.net/views/interest-areas.php?id=MTY=

http://domain.net/interest-areas.php?id=MTY=

我已经参考了LINK,但现在仍然得到了预期的结果

2 个答案:

答案 0 :(得分:0)

您可以尝试以下代码:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^users/
RewriteRule ^(.*)$ views/$1 [L]

这里,[L] -flag在此规则之后停止重写,防止可能的圆反应等

答案 1 :(得分:0)

在根目录中尝试此规则,

RewriteEngine on
RewriteBase /views/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).php$ views/$1.php [QSA,L]