Tuesday, 24 January 2012

Different redirects in htaccess

redirect from a folder to an url
Redirect 301 /folder/test.html http://www.yourdomain.com/directory

If you need to redirect http://yourdomain.com to http://www.yourdomain.com
1.check whether mod_rewrite is enabled on your server
2.you can put this in your .htaccess file as:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=permanent,L]

 www to non-www

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

http to https
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]

No comments:

Post a Comment