Redirection through .htaccess file
To redirect a single page
Redirect 301 /oldpage.html http://www.example.com/newpage.html
To redirect the entire site to another domain.
Redirect 301 / http://www.example.com/
Redirect www.example.com to example.com
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
Redirect example.com to www.example.com
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]
Redirect example.com/index.php to example.com/
Options +FollowSymLinks
RewriteEngine on
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3, 9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
To change the file extension.
RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php
Add A Comment