0

I have a website using wildcard subdomains.

I need to change the domain and redirect all old pages to the new domain.

For example: I want to redirect this page x.olddomain.example/stackoverflowto x.NewDomain.example/stackoverflow

without making any changes on the subdomains folders.

I used this code :

RewriteCond %{HTTP_HOST} ^(.+\.)?olddomain.example$ [NC]
RewriteRule ^ http://%1newdomain.example%{REQUEST_URI} [R=301,L]

But the result is: x.olddomain.example/stackoverflow redirectw to x.olddomain.example/?name=stackoverflow

Please note : that the problem occurs when you try to enter the domain directly to browser .. but if you are on the subdomain it's working fine

If you are browsing the page x.olddomain.example and you clicked on this link through that page x.olddomain.example/stackoverflow, then it redirects fine to x.newdomain.example/stackoverflow

But if you tried to enter x.olddomain.example/stackoverflow directly through the browser it redirects to x.newdomain.example/?name=stackoverflow

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
  • You should check https://stackoverflow.com/questions/8730298/redirect-any-sub-domain-to-a-page-on-main-domain and https://stackoverflow.com/questions/8569399/redirect-subdomain-to-new-domain – juanbits Aug 16 '18 at 03:26
  • i checked it but still not working !!! – Ahmed Mamdouh Aug 16 '18 at 03:29
  • Start by removing the space after the `ˆ`. There is nothing in what you have shown that can do a redirection to an URL with `?name=something` in it. So you have other parts of your configuration that come into play. – Patrick Mevzek Aug 16 '18 at 15:19

0 Answers0