Mod_rewrite noob question

jordanj77

New member
Oct 18, 2009
195
7
0
I have links like: example.com/?var=123

I want: example.com/123 (users type this, but it should function like above)

Thanks for the help!


 


Code:
RewriteEngine On
RewriteBase /

# Always serve files that exist first
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

# If Var is always numeric, use this
RewriteRule ^\d+$ index.php?var=$1 [L]

# If Var is always word characters (a-z, 0-9), use this
RewriteRule ^\w+$ index.php?var=$1 [L]
 
Thanks uplinked,

Couldn't get that to work but managed to do it with this:

RewriteRule ^([0-9]+)/?$ index.php?var=$1 [L]

/thread