如果只给出域(没有路径),则重写所有内容都会失败

问题描述 投票:0回答:1

我正在尝试将所有内容重定向到其他网址:

RewriteEngine on

# This regular expression should match all, including empty strings!
RewriteRule ^(.*)$ http://www.google.com/ [R=301,NC]

但只要给出路径,它才会起作用:

  • http://www.mydomain.com/x工作正常
  • http://www.mydomain.com/失败了
  • http://www.mydomain.com失败了

更新:此错误行为仅出现在我的本地设置(Win7 / XAMPP / Apache / 2.2.21)上,其他所有其他重定向都像charme一样工作。我在生产服务器上尝试了上面的代码,它完美地工作。

apache .htaccess mod-rewrite
1个回答
0
投票
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

测试此代码并报告反馈

© www.soinside.com 2019 - 2024. All rights reserved.