.htaccess文件重定向错误

时间:2014-10-30 16:22:18

标签: apache .htaccess

在新服务器上创建开发站点后,htaccess文件错误地重定向链接。例如,如果单击example.com上的链接example.com/test,则会尝试重定向到example.com/example.com/test。我如何更正下面的htaccess文件:

<IfModule mod_rewrite.c>
    # Turn on the Rewrite Engine
    RewriteEngine On

    RewriteBase /

    # If the file or directory exists, show it
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]

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

    # Blank queries get sent to the index
    RewriteRule ^$ /index.php [L]

    # All other queries get sent to the index as index.php/whatever
    RewriteRule ^(.*)$ /index.php?$1 [L]
</IfModule>

<ifModule mod_headers.c>
 Header set Connection keep-alive
</ifModule>

1 个答案:

答案 0 :(得分:0)

RewriteBase下方插入此规则,将/example.com/test重定向到/test

RewriteRule ^example\.com/(.+)$ /$1 [L,NC,NE,R=302]