在新服务器上创建开发站点后,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>
答案 0 :(得分:0)
在RewriteBase
下方插入此规则,将/example.com/test
重定向到/test
:
RewriteRule ^example\.com/(.+)$ /$1 [L,NC,NE,R=302]