URL Rewriting Using .htacess file
Our Aim is to
http://www.example.com/test/blog/var1/testFile.html
into dynamic URL
http://www.example.com/test/testFile.php?var1=var1&var2=testFile
using .htacess file
Create .htacess file in test directory
Now you directory structure is
www.example.com/test/
.htacess
testFile.php
In .htacess file write the code
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [QSA]
Now in testFile.php your code will be there
If you type URL in Browser
http://www.example.com/test/blog /var1/testFile.html
it will execute on server as
http://www.example.com/test/testFile.php?var1=var1&var2=testFile
if you want todo external redirecting the just change the .htacess code
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [R=301,L]
Tuesday, September 1, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment