【问题标题】:Using htaccess remove folder name [duplicate]使用 htaccess 删除文件夹名称 [重复]
【发布时间】:2017-02-17 06:42:22
【问题描述】:

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

我想要网址结构

http://example.com/views/interest-areas.php?id=MTY=

http://example.com/interest-areas.php?id=MTY=

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

【问题讨论】:

  • /views/ fodler 中是否有 .htaccess?

标签: php .htaccess


【解决方案1】:

你可以试试我下面的代码:

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

这里,[L]-标志在这条规则之后停止重写,防止可能的循环反应等

【讨论】:

  • 第二行有意想不到的后果。
【解决方案2】:

在根目录试试这个规则,

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    • 2010-11-18
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 2016-09-17
    相关资源
    最近更新 更多