简体   繁体   English

Htaccess将所有内容从域/文件夹重定向到另一个域

[英]Htaccess redirect all content from domain/folder to another domain

I have a website here: 我这里有一个网站:

Wordpress Site Wordpress网站

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: 现在,我需要重定向到该域/目录下的所有请求otherdomain,在这种情况下designcenter.com.ve同时保持文件夹层次,因为它是,例如:

http://olddomain/wordpress/post - to - http://newdomain/post or maybe http://newdomain/wordpress/post

Already tried some answers here, but no still luck, no redirecting and plus had to delete htaccess and restore permalinks on wordpress. 已经尝试了一些答案,但没有运气,没有重定向和加号必须删除htaccess并恢复wordpress上的永久链接。

Somebody could shed some light on this? 有人可以对此有所了解吗?

Thanks in advance! 提前致谢!

Give this a shot. 试一试。

 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteRule ^folder1(.*)$ http://www.newdomain.com/$1 [L,R=301]

    </IfModule>

I always prefer the popular Redirection plugin. 我总是喜欢流行的Redirection插件。 Since you don't need to touch the .htaccess file. 因为您不需要触摸.htaccess文件。 And you can manage everything from Wordpress Admin itself 您可以从Wordpress Admin本身管理所有内容

Update:2 : You can find all the basic redirect rules here . 更新:2 :您可以在此处找到所有基本重定向规则。

Use this in regex... (Based on your usecase) 在正则表达式中使用它...(基于您的用例)

 Source: /(.*) 
 Target: http://newdomain.com/$1

UPDATE : I noticed... you haven't updated the permalinks in your 2nd site... Do that first and then also see the site URL is properly mentioned in your wordpress admin settings page. 更新 :我注意到......你没有更新你的第二个站点中的固定链接...首先执行此操作,然后在wordpress管理设置页面中看到网站URL已正确提及。

You just need this rule but make sure this rule is your first rule in your DocumentRoot/.htaccess of olddomain.com : 您只需要此规则, 但请确保此规则是您在 olddomain.com DocumentRoot/.htaccess第一条规则

RewriteRule ^wordpress(/|$) http://www.newdomain.com%{REQUEST_URI} [L,NC,NE,R=301]

In case your .htaccess is in /wordpress/.htaccess then use: 如果你的.htaccess在/wordpress/.htaccess那么使用:

RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,NE,R=301]

as your first rule . 作为你的第一条规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM