mod_rewrite noob here

GVNPublic123
GVNPublic123 used Ask the Experts™
on
Hello,

So I have a site:
domain.com/index.php?ref=154

ref contains ID of referrer who gets an award if someone signs up trough his link.
However, Id like to make link shorter and look like this:
domain.com/?ref=154

I've never used mod_rewrite before, but I think it could do this job. I only want this to work with index.php.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Or better yet if I name it r instead of ref.
domain.com/index.php?r=154
domain.com/?r=154
RewriteCond %{REQUEST_URI} ^/index\.php\?r=(.*)
RewriteRule .* /?r-%1
Top Expert 2004

Commented:
I don't think you want mod_rewrite at all for this.  What you want is a properly set DefaultDocument directive.

I'm presuming you want users to click on a link for "http://domain1.com/?r=154" and arrive at your index.php.  Is that correct?
Most Valuable Expert 2011
Top Expert 2016
Commented:
On my server these statements are equivalent.  I do not rewrite URLs at all.
domain.com/index.php?r=154
domain.com/?r=154

Author

Commented:
Ray, I just tried it without mod-rewrite and it works. :P

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial