PDA

View Full Version : .htaccess redirect old domain subpages to new domain index



Fli
03-21-2014, 12:24 PM
Hello, i already tried .htaccess rule to redirect old domain to new domain, including all subpages - here it is (http://internetlifeforum.com/showthread.php?t=3549). But now i want to redirect old domain (incl. subpages) to new domain INDEX page only (not relevant subpages, only one page on new domain).

example:
old.com/page.php -> new.com

ho to achieve it please?


Temporary fix is to use this redirect (http://internetlifeforum.com/showthread.php?t=3549) and in newdomain .htaccess file, add rule to redirect all non existing 404 visitors to index:


ErrorDocument 404 /

or

RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* / [R=301]


There is another quite nice tutorial which works and also count visits from old domain:


1. old domain .htaccess:




Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://mynewdomain.com/?go=sometexthere (http://mynewdomain.com/?go=home) [R=301,L]



2. newdomain created counter.txt file and chmod 777


3. added following code to the index.tpl file on newdomain




{php}
if ($_GET['go'] == sometexthere) {
$count = file_get_contents('counter.txt');
file_put_contents('counter.txt', ++$count);
}
{/php}

or remove {php} tags and add to index.php