shawon2170
New member
Here are some tips on how to do redirects and url rewrite using .htAccess file in Linux servers.
Do a 301 redirect of a page to domain name:
Code:
Redirect 301 /index.php http://www.webcosmoforums.com/
301 redirect of an entire site to a different URL:
Code:
Redirect 301 / http://www.webcosmoforums.com/
Redirect a page to to another folder:
Code:
Redirect /myPage.html http://www.webcosmoforums.com[URL="http://mt-example.com/newdirectory/"]/myfloder/
Redirect an old file to a new file:
Code:
Redirect /olddirectory/oldfile.html [URL="http://www./newdirectory/newfile.html"]http://www.webcosmoforums.com/newdirectory/newfile.html
301 Redirect to make users access the site without www:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.webcosmoforums.com\.com$ [NC]
RewriteRule ^(.*)$ http://webcosmoforums.com.com/$1 [L,R=301]
301 Redirect to make users access the site with www:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.webcosmoforums.com\.com$ [NC]
RewriteRule ^(.*)$ http://www.webcosmoforums.com.com/$1 [L,R=301]
Redirect visitors to use the secure version of your domain:
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.webcosmoforums.com.com/$1 [R,L]
Use https:// for a particular folder:
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.webcosmoforums.com.com/somefolder/$1 [R,L]
Do a 301 redirect of a page to domain name:
Code:
Redirect 301 /index.php http://www.webcosmoforums.com/
301 redirect of an entire site to a different URL:
Code:
Redirect 301 / http://www.webcosmoforums.com/
Redirect a page to to another folder:
Code:
Redirect /myPage.html http://www.webcosmoforums.com[URL="http://mt-example.com/newdirectory/"]/myfloder/
Redirect an old file to a new file:
Code:
Redirect /olddirectory/oldfile.html [URL="http://www./newdirectory/newfile.html"]http://www.webcosmoforums.com/newdirectory/newfile.html
301 Redirect to make users access the site without www:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.webcosmoforums.com\.com$ [NC]
RewriteRule ^(.*)$ http://webcosmoforums.com.com/$1 [L,R=301]
301 Redirect to make users access the site with www:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.webcosmoforums.com\.com$ [NC]
RewriteRule ^(.*)$ http://www.webcosmoforums.com.com/$1 [L,R=301]
Redirect visitors to use the secure version of your domain:
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.webcosmoforums.com.com/$1 [R,L]
Use https:// for a particular folder:
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.webcosmoforums.com.com/somefolder/$1 [R,L]