【问题标题】:Htaccess rewriterule /a to /a/bHtaccess 重写 /a 到 /a/b
【发布时间】:2015-11-06 05:31:48
【问题描述】:

我尝试准备从目录/a/ 到子文件夹/a/b/ 的重写规则,但我收到我的重写规则是循环的信息,所以我收到output URL 作为localhost/a/b/a/b/a/a/b 以请求localhost/a/ .我想收到:

localhost/a and rewrite to localhost/a/b

我试试:

RewriteEngine On
RewriteCond %{REQUEST_URI} !=/a/b
RewriteRule ^/a(.*)$ /a/b/$1 [L]

【问题讨论】:

    标签: php regex apache .htaccess mod-rewrite


    【解决方案1】:

    /a/.htaccess里面有这个规则:

    RewriteEngine on
    RewriteBase /a/
    
    RewriteRule ^((?!b/).*)$ b/$1 [NC,L,R=302]
    

    如果您想从此重定向中跳过实际文件/目录,请使用:

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^((?!b/).*)$ b/$1 [NC,L,R=302]
    

    【讨论】:

      猜你喜欢
      • 2016-02-23
      • 1970-01-01
      • 1970-01-01
      • 2014-09-14
      • 1970-01-01
      • 2011-10-20
      • 2019-09-19
      • 2021-11-28
      • 1970-01-01
      相关资源
      最近更新 更多