【问题标题】:htaccess RewriteCond and RedirectMatchhtaccess RewriteCond 和 RedirectMatch
【发布时间】:2015-11-18 14:37:59
【问题描述】:

我在我的 .htaccess 文件中启用了 RewriteEngine。我有条件从任何请求中删除“www”。这工作得很好。但是,我也在使用 RedirectMatch 进行 301 重定向。除了将来自原始传入 url 的请求 URI 附加到我 301 重定向到的 url 的末尾之外,这也有效。

输入网址:

http://www.example.com/newplate

输出网址:

http://example.com/contact/motorv.php?/newplate

现有的 .htaccess 文件

AddOutputFilter INCLUDES .shtml .html .htm .php


RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,L]


#straight 301 redirects
RedirectMatch 301 ^/newplate(.*) /contact/motorv.php


#if request is not an existing file or directory then redirect to
#codeigniter boot.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ boot.php?/$1 [L,QSA]

应该如何解决这个问题?有没有我忽略或写错的地方?

【问题讨论】:

    标签: apache .htaccess http


    【解决方案1】:

    你可以使用:

    #straight 301 redirects
    RewriteRule ^newplate(.*) /contact/motorv.php [NC,L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-25
      • 2010-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多