htaccess将所有内容从域/文件夹重定向到另一个域 [英] Htaccess redirect all content from domain/folder to another domain
问题描述
我在这里有一个网站:
现在,我需要将对该域/目录的所有请求重定向到otherdomain,在这种情况下为 designcenter.com.ve ,同时保持文件夹层次结构不变,例如:
Now, i need to redirect all requests to that domain/directory to otherdomain, in this case designcenter.com.ve while keeping folder hierarchy as it is, for example:
http://olddomain/wordpress/post - to - http://newdomain/post or maybe http://newdomain/wordpress/post
已经在这里尝试了一些答案,但是仍然没有运气,没有重定向,还不得不删除htaccess并恢复wordpress上的永久链接。
Already tried some answers here, but no still luck, no redirecting and plus had to delete htaccess and restore permalinks on wordpress.
有人可以对此有所了解吗?
Somebody could shed some light on this?
预先感谢!
推荐答案
您只需要此规则,但请确保此规则是 DocumentRoot / .htaccess
中的第一条规则> olddomain.com :
RewriteRule ^wordpress(/|$) http://www.newdomain.com%{REQUEST_URI} [L,NC,NE,R=301]
如果您的.htaccess位于 /wordpress/.htaccess
中,则使用:
In case your .htaccess is in /wordpress/.htaccess
then use:
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,NE,R=301]
作为您的第一条规则。
这篇关于htaccess将所有内容从域/文件夹重定向到另一个域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!