(1) Redirect site from http to https :
add the below in .htaccess file in public_html
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
(2) Redirecting a domain to another domain via .htaccess
Example :- redirect vivek.com to google.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^vivek\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.vivek\.com$
RewriteRule ^/?$ “http\:\/\/www\.google\.com\/” [R=301,L]
(3) Redirect users to access the site with WWW
Example :- redirect vivek.com to www.vivek.com
add the below in .htaccess file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^vivek\.com$ [NC]
RewriteRule ^(.*)$ http://www.vivek.com/$1 [L,R=301]
(4) Redirect page to another page within public_html
Example1 :- to redirect home.html to index.php
RewriteEngine on
RewriteRule ^home.html$ index.php
Example2 :- rewrite site vivek.com/kb/index.php to vivek.com/blog/index.html
Go to kb directory and create a .htaccess file
#cd public_html/kb
#touch .htaccess
#vi .htaccess
RewriteEngine on
RewriteRule ^index.php$ /blog/index.html
No comments:
Post a Comment