Redirect sub domain to main domain without effecting sub folders with .htaccess

好久不见. 提交于 2019-12-25 04:23:13

问题


My situation is as follows:

  • I've have a new website at my main domain. Example: mywebsite.com.
  • My old portfolio is located at an old sub domain: portfolio.mywebsite.com.
  • All portfolio items can be found in a sub directory at the portfolio site.
  • So portfolio item 1 can be found at portfolio.mywebsite.com/item-1, etc.
  • The sub domain is running WordPress with Multisite enabled.
  • The sub domain and main domain are hosted by different web hosts.

I want to redirect all traffic from portfolio.mywebsite.com to mywebsite.com/portfolio. But I don't want to redirect traffic from the portfolio items, since I don't have time to build a new portfolio yet. Therefor I also need to be able to acces the wp-admin folder on the sub domain.

In short: How do I redirect traffic from portfolio.mywebsite.com to mywebsite.com/portfolio without effecting all the other urls? :)

Best regards,

Michael


回答1:


If i understand well your problem i think that you can use a simple plugin for redirection like Safe Redirect Manager

It's very simple to use.




回答2:


Try placing this redirect rule in root of portfolio.mywebsite.com as very first rule:

RewriteEngine On

RewriteRule ^([^/]+)/?$ http://mywebsite.com/portfolio [L,NE,R=302]


来源:https://stackoverflow.com/questions/28915825/redirect-sub-domain-to-main-domain-without-effecting-sub-folders-with-htaccess

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