【问题标题】:how to clear url's on second level subfolder如何清除二级子文件夹中的url
【发布时间】:2015-07-09 12:15:06
【问题描述】:

我有一个网站,它有子文件夹(内容)。我正在通过 .htaccess 清除扩展:

http://example.com/k/page.phphttp://example.com/k/page

现在我有了另一个子文件夹:

http://example.com/e/k/page.php

并想将其用作http://example.com/e/k/page

但我的 htaccess 不允许我这样做。

这是我的 .htaccess 文件:

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

RewriteRule ^([^/]+)/$ $1.php [L]

RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php [L]

我该怎么做?我试过了:

RewriteRule ^([^/]+)/([^/]+)//([^/]+)$ /$1/$2/$3.php [L]

它在 /e/k/page 上工作,但破坏了第一级 /k/page

任何帮助都会很棒。

最好的问候。

【问题讨论】:

    标签: php .htaccess mod-rewrite


    【解决方案1】:

    我通过添加额外的行找到了解决方案:

    RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3.php [L]
    

    希望它适用于需要这样做的人。

    最好的。

    【讨论】:

      猜你喜欢
      • 2015-01-21
      • 2023-03-26
      • 1970-01-01
      • 2017-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多