Redirect sub domain to main domain without effecti

2019-08-17 17:24发布

问题:

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]