Home How can I redirect all traffic to one domain to the same location at another domain
Reply: 1

How can I redirect all traffic to one domain to the same location at another domain

wordSmith
1#
wordSmith Published in 2017-11-09 14:48:58Z

I'm trying to redirect all traffic to one domain to another. No matter what the subdomain or directory within. It should go to the same place at this other domain.

zweeue.com -> zoeyt.com

s.zweeue.com -> s.zoeyt.com

zweeue.com/art/ -> zoeyt.com/art/

Now here's the trick, at the other domain, I have a mod rewrite that sends all traffic for files and directories that do not exist to l.php

So zoeyt.com/art exists so zweeue.com/art/ would go to zoeyt.com/art/

But zweeue.com/mvs does not so zoeyt.com/mvs would go to zoeyt.com/mvs/. Right now, zweeue.com/mvs get a 404, but zweeue.com/art/ should go to zoeyt.com/art/ because /art/ exists there. Everything at zweeue.com goes to zoeyt.com with the below first htaccess file. The second mod rewrite block below is the seperate htaccess file on the seperate host for zoeyt.com

How can I do this successfully? Currently zweeue.com/mvs goes to zoeyt.com/ and not zoeyt.com/mvs, which zoeyt's htaccess would send to l.php.

Here is what is in the redirect htaccess at the first domain, zweeue.com:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^(.*)$ http://www.zoeyt.com/$1 [L,R=301]

</IfModule>

Here is what is in the second domain's htacccess file (zoeyt):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /l.php [L]
</IfModule>
anubhava
2#
anubhava Reply to 2017-11-09 16:37:17Z

Change your first .htaccess to this:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^ http://www.zoeyt.com%{REQUEST_URI} [L,R=301,NE]

</IfModule>

Second domain's htacccess file (zoeyt):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ l.php [L]

</IfModule>

Use of %{REQUEST_URI} instead of $1 ensures you send full URI to target not a relative value captured in $1.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.315178 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO