A .htaccess rule that will divert any page in another folder
Posted by Raj
A .htaccess rule that will divert any page in another folder
1)If you want to redirect http://test.com/f1/ to http://test.com/f2/.
.htaccess file will be.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^f1.*$ http://test.com/f2/ [R=301,L]
2)If you want to redirect http://test.com/f1/test.html to http://test.com/f2/test.html.
.htaccess file will be.
Options +FollowSymLinks
RewriteEngine On
RewriteRule RewriteRule ^f1/(.*)$ http://test.com/f2/$1 [R=301,L]
3) If you want to redirect http://test.com/ to http://www.test.com/.
.htaccess file will be.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test.com [NC]
RewriteRule ^(.*)$ http://www.test.com/$1 [R=301,L]
4) If you want to redirect http://test.com/ to https://test.com/.
.htaccess file will be.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.test.com/$1 [R,L]
1)If you want to redirect http://test.com/f1/ to http://test.com/f2/.
.htaccess file will be.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^f1.*$ http://test.com/f2/ [R=301,L]
2)If you want to redirect http://test.com/f1/test.html to http://test.com/f2/test.html.
.htaccess file will be.
Options +FollowSymLinks
RewriteEngine On
RewriteRule RewriteRule ^f1/(.*)$ http://test.com/f2/$1 [R=301,L]
3) If you want to redirect http://test.com/ to http://www.test.com/.
.htaccess file will be.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test.com [NC]
RewriteRule ^(.*)$ http://www.test.com/$1 [R=301,L]
4) If you want to redirect http://test.com/ to https://test.com/.
.htaccess file will be.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.test.com/$1 [R,L]
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
.htaccess,
301 Redirect,
mod_rewrite apache,
PHP,
PHP interview questions and answers,
redirect a url
.You can leave a response, or trackback from your own site.