Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    mod_rewrite with old and new domain

    Hi all,

    I have two domains: olddomain.com and newdomain.com. Both domains point to the same dir on local disk with the same .htaccess file.
    I would like to redirect all requests of olddomain.com/somepath.html to newdomain.com/somepath.html. I have the following lines in my .htaccess file:

    Code:
    RewriteCond %{HTTP_HOST} !^newdomain.com$ [NC]
    RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
    When I request olddomain.com/somepath.html my apache redirects me to the newdomain.com/index.php instead of newdomain.com/somepath.html.

    Could anyone advice me how to fix my .htaccess config?

    Kind regards,
    Rob

  2. #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,650
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Is that your only rewrite? It looks like you are redirecting properly, but after that it gets redirected or rewritten again.

  3. Users who have thanked Inigoesdr for this post:

    rkoziol7 (02-13-2012)

  4. #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I use joomla standard .htaccess modified with two mentioned lines:

    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^newdomain.com$ [NC]
    RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
    
    RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
    RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    RewriteRule .* index.php [F]
    
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    RewriteCond %{REQUEST_URI} !^/index\.php
    
    RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php [L]
    Kind regards,
    Rob


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •