1

我的 htaccess 规则在 Apache 中运行良好,但我不得不更改为 LiteSpeed 并且我的页面无法正常运行(例如,如果我键入http://domain.com/article/some-articlehttp://domain.com/article之类的 url /标签/一些标签)。也许有人处理过类似的问题?在服务器日志中,我得到:达到最大重定向数。

我的 htaccess:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]     

RewriteCond %{REQUEST_URI}  .article.php/tags/([^/]+)$     [NC]
RewriteRule  ^(.*)$      article.php?tag=%1 [L,NC,QSA]

RewriteCond %{REQUEST_URI}  .article.php/([^/]+)$     [NC]
RewriteRule  ^(.*)$      article.php?art=%1 [L,NC,QSA]

RewriteCond %{REQUEST_URI}  .article.php/(.+)$     [NC]
RewriteRule  ^(.*)$      http://domain.com/article/$1 [L,R=301]

我会感谢你的帮助

4

1 回答 1

0

我向你展示了我是如何处理这个问题的——我不得不改变规则和顺序——我认为有一些循环重定向:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

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


    RewriteCond %{REQUEST_URI}  .articles/tags/([^/]+)$     [NC]
    RewriteRule  ^(.*)$      articles.php?tag=%1 [L,NC,QSA]

    RewriteCond %{REQUEST_URI}  .articles/([^/]+)$     [NC]
    RewriteRule  ^(.*)$      articles.php?article=%1 [L,NC,QSA]

    RewriteCond %{REQUEST_URI}  .articles.php/tags/([^/]+)$     [NC]
    RewriteRule  ^(.*)$      articles/tags/%1 [L,R=301]

    RewriteCond %{REQUEST_URI}  .articles.php/([^/]+)$     [NC]
    RewriteRule  ^(.*)$      articles/%1 [L,R=301]


    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # browser requests PHP
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
    RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

    # check to see if the request is for a PHP file:
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^/?(.*)$ /$1.php [L]        

    #301 redirect error page (instead of 302 - for SEOD reason)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . /page-not-found [L,R=301] 

</IfModule>
于 2015-11-21T20:03:54.957 回答