Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 重定向301域和某些页面_Apache_.htaccess_Redirect_Mod Rewrite_Seo - Fatal编程技术网

Apache 重定向301域和某些页面

Apache 重定向301域和某些页面,apache,.htaccess,redirect,mod-rewrite,seo,Apache,.htaccess,Redirect,Mod Rewrite,Seo,我需要通过htaccess将我的旧域.com重定向到新域.com 新域具有不同的URL old domain.com/aboutus.html至new domain.com/us.html old-domain.com/contact-us.html至new-domain.com/form.html 。。。。。 所有其他页面old-domain.com/xxxxxxxxxx重定向到主页new-domain.com 谢谢假设您使用的是apache http服务器,您需要在http服务器中启用重写

我需要通过htaccess将我的旧域.com重定向到新域.com

新域具有不同的URL

old domain.com/aboutus.html
new domain.com/us.html

old-domain.com/contact-us.html
new-domain.com/form.html

。。。。。

所有其他页面old-domain.com/xxxxxxxxxx重定向到主页new-domain.com


谢谢

假设您使用的是apache http服务器,您需要在http服务器中启用重写模块,并且需要实现以下重写规则:

RewriteEngine on
RewriteRule ^/?aboutus\.html$ /us.html [R=301,END]
RewriteRule ^/?contact-us\.html$ /form.html [R=301,END]
RewriteRule ^ / [R=301,END]

这些规则可以放在http服务器的主机配置中。如果您无法访问该文件,则必须使用分布式配置文件(“.htaccess”),该文件应放在http主机的
DOCUMENT\u ROOT
文件夹中。请记住,您需要启用此类文件的解释。在这种情况下,请检查apache http服务器文档中的
AllowOverride
指令。

欢迎使用此指令,请在您的问题中添加您的htaccess规则文件,谢谢。