How to 301 redirect all pages from one domain to one single page on a different domain

我的梦境 提交于 2019-12-23 04:36:37

问题


I´m trying to do a 301 redirect in a htacess file. I want to point all pages on one domain to one single page on another domain and I do not want to manually redirect all single pages.

Ex: www.olddomain.com/1.html and www.olddomain.com/2.html should both point to www.newdomain.com.

Hope anyone could help me.


回答1:


RewriteCond %{HTTP_HOST} .*olddomain\.com$
RewriteRule ^ http://www.newdomain.com/one-single-page.html [L,R=301]



回答2:


I had the same problem but this works fine for me to accomplish what you want, i actually need to opposite, for each page from old domain to redirect to new domain but keep inner structure so ill keep looking i guess!

redirectMatch 301 ^/ http://www.newdomain.com


来源:https://stackoverflow.com/questions/3959477/how-to-301-redirect-all-pages-from-one-domain-to-one-single-page-on-a-different

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!