Showing posts with label htaccess url. Show all posts
Showing posts with label htaccess url. Show all posts
Redirect URLs using .htaccess
Posted by Raj
Redirect URLs using .htaccess :
You can use .htaccess to redirect users to a different URL(redirect a url)
Sometimes you need to redirect some URL and/or page on your site to another one.
using the “Redirect” directive:
Redirect /folder http://www.example.com/newfolder
Another useful directive is the RedirectMatch
RedirectMatch "\.html$" http://www.example.com/index.php
This will redirect all requests to files that end with .html to the index.php file.
One of the more powerful tricks of the .htaccess hacker is the ability to rewrite URLs
simple rewriting
all requests to whatever.htm will be sent to whatever.php:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]
RewriteRule ^menu.html menu.php
Complex rewrite rule:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^Project/([^/]+)/([^/]+) /test.php?city=$1&file=$2 [NC]
would allow you to present this link as..
http://localhost/Project/Mumbai/CST
and in the background have that transparently translated, server-side, to..
http://localhost/test.php?city=Mumbai&file=CST