PDA

View Full Version : .htaccess how redirect one page to another



Fli
07-18-2013, 03:31 PM
If you have one subpage and you wish to redirect all traffic to another page, you can use this code in .htaccess file



redirect 301 /page.php http://domain.com/page.php

Note that old page is only /page.php or page.php , not http://

then if you need to redirect including URL parameters (page.php?name=john&surname=doe) you can redirect .php page to a different page with same parameters using following .htaccess file lines:



RewriteEngine on
RewriteRule ^local-source-page\.php$ https://new.domain.tld/newpage.php [L,R=301]




You can also use redirect htaccess generator like http://www.rapidtables.com/web/tools/redirect-generator.htm
There is whole domain redirect: http://internetlifeforum.com/editing-coding-programming/1645-htaccess-redirect-old-domain-new-domain-index/

John8
11-18-2013, 12:12 PM
You can ADD this to your .htaccess and redirect non www to www... This will help your SEO because google will not be able to get duplicate cotent


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

david007
08-18-2023, 06:12 AM
To redirect one page to another using .htaccess, use the following code:

Redirect 301 /old-page.html http://www.example.com/new-page.html.

Replace "/old-page.html" with the relative path of the old page and "http://www.example.com/new-page.html." with the full URL of the new page you want to redirect to. The "301" indicates a permanent redirect.