Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Redirect every single page from old subdomain->new subdom |
|
Author |
|
bra_mik
Joined: 11 May 2015 Posts: 1
|
Posted: Tue 12 May '15 8:37 Post subject: Redirect every single page from old subdomain->new subdom |
|
|
Wordpress installation (WPML with 3rd level domain es. site. com, fr. site. com).
I need to redirect page from old subdomain to a new subdomain
Example:
esp.site.com/oldpage -> es.site.com/newpage (different subdomain)
esp.site.com/oldpage1 -> es.site.com/newpage
esp.site.com/oldpage2 -> es.site.com/newpage
Source site is very chaotic (static pages + wp pages) and there are no clear rule for redirection (no regex )
So I need to redirect every single page but syntax:
Redirect 301 esp.site.com/oldpage http:// es.site.com/newpage
doesn't work!
I think "esp.site.com" in source page is not acceptable syntax
which is the correct syntax ?
Can I manage all from one .htaccess file in main root (www) or should I create "esp" directory (and point old subdomain to it - one for every language) and put .htaccess in every directory with redirection ? |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3118 Location: Hilversum, NL, EU
|
Posted: Wed 13 May '15 9:54 Post subject: |
|
|
To redirect all pages from the old to the new, try:
Code: | <IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule> |
or when you have more domains Code: | <IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule> |
mod_rewrite should be enabled. |
|
Back to top |
|
|
|
|
|
|