Help me with mod rewrite

New to mod_rewrite? This is a good place to start.

Help me with mod rewrite

Postby fonfanclub » Mon Apr 27, 2009 7:39 am

Help me with mod rewrite

Code: Select all
http://blog.example.com/blog.php?id=100


to

Code: Select all
http://www.example.com/b100.html


Thank You
fonfanclub
 
Posts: 2
Joined: Mon Apr 27, 2009 12:28 am

Postby richardk » Mon Apr 27, 2009 8:48 am

Are they on two different servers?
Can you access blog.php by going to something similar to example.com/blog/blog.php?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Re: Help me with mod rewrite

Postby fonfanclub » Mon Apr 27, 2009 7:32 pm

like this ?

Code: Select all
http://www.example.com/blog.php?id=100


to

Code: Select all
http://www.example.com/b100.html
fonfanclub
 
Posts: 2
Joined: Mon Apr 27, 2009 12:28 am

Postby richardk » Tue Apr 28, 2009 11:22 am

For /b100.html to /blog.php?id=100 (with no change of (sub) domain) the following should work in a .htaccess file in your document root
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^b([0-9]+)\.html$ /blog.php?id=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 8 guests

cron