friendly URL

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

friendly URL

Postby danny » Sat Mar 10, 2007 9:13 pm

I am looking to make a page, example.com where if example.com/index.php is called, that is displayed, yet if example.com/something is called, the page example.com/index.php?ID=something is displayed.

The mod rewrite code that I've tried for this is:
Code: Select all
RewriteRule ^(.+)$ /index.php?ID=$1

This however is redirecting the example.com/index.php page to example.com/index.php?ID=index.php, and if I go to example.com/something, it causes the page not to redirect properly.

Any help is much appreciated.

edit:
Never mind, I eventually found it:
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?ID=$1 [QSA,L]
danny
 
Posts: 2
Joined: Sat Mar 10, 2007 8:43 pm

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 30 guests

cron