logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: 301 redirect not working properly with add-on domains ...
Author
Revived



Joined: 23 Nov 2016
Posts: 1

PostPosted: Wed 23 Nov '16 16:02    Post subject: 301 redirect not working properly with add-on domains ... Reply with quote

I have a primary/account domain (PrimaryDomain.com) and a couple add-on domains (AddOnDomain1.com and AddOnDomain2.com) I've recently switched the content from AddOnDomain1.com to AddOnDomain2.com and I want everything to redirect to the exact same location (folders, files, images, etc.)

Here's what I have in .htaccess of my public_html folder (for PrimaryDomain.com):

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.AddOnDomain1\.com$
RewriteRule (.*) http://AddOnDomain2.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^AddOnDomain1\.com$
RewriteRule (.*) http://AddOnDomain2.com/$1 [R=301,L]


It trys to redirect but here's what happens (with an image as an example). When I enter:

http://AddOnDomain1.com/img/logo.png

It redirects to:

http://AddOnDomain2.com/**AddOnDomain1**/img/logo.png

Notice how it adds that folder (in bold)?...which of course is the add-on domain directory name. Anyone aware of a fix for this scenario?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sat 26 Nov '16 10:50    Post subject: Reply with quote

Code:
RewriteCond %{HTTP_HOST}   ^fAddOnDomain1\.com [NC]
RewriteRule ^/(.*)         http://AddOnDomain2.com/$1 [L,R]
Back to top


Reply to topic   Topic: 301 redirect not working properly with add-on domains ... View previous topic :: View next topic
Post new topic   Forum Index -> Apache