Mod rewrite 将所有页面(包括子页面)重定向到新域
我试过这个:Mod rewrite 将所有页面(包括子页面)重定向到新域,mod-rewrite,Mod Rewrite,我试过这个: RedirectMatch 301 (.*) http://olddomain.com$1 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC] RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301] 但不会重定向所有子页面。是否在Apache配置中设置指令AllowOverride all? mod_rewrite模块工作正常吗
RedirectMatch 301 (.*) http://olddomain.com$1
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
但不会重定向所有子页面。是否在Apache配置中设置指令
AllowOverride all
?
mod_rewrite模块工作正常吗?试试这个
RewriteEngine On
# Take care of www.old.com.au
RewriteCond %{HTTP_HOST} ^www.old.com.au$ [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [L,R=301]
RewriteCond %{QUERY_STRING} ^attachment_id=([0-9]*)$ [NC]
RewriteRule ^$ http://www.new.com/? [R=301,NE,NC,L]
很简单,我只是用它来为我自己做一些特殊的重写,下面是你的代码: 将其放入/www/.htaccess文件中:
RewriteEngine on
// Rules to redirect to another domain
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301,NC]
请检查,以获得另外3种重定向方法。请注意,
AllowOverride All
仅适用于apache 2.2及更高版本