1

I have a domain, example.com.

Here is my apache2 ReWrite rule:

RewriteEngine on
RewriteRule ^([^/.]+)/?$ index.php?uname=$1 [L]

When I go to http://example.com/Eamorr, http://example.com/Eamorr appears in the address bar of my browser.

I want http://www.example.com/index.php?uname=Eamorr to appear in the address bar! (my javascript needs to parse the GET arguments)

Is this possible?

Many thanks in advance,

0

1 Answer 1

4

Add a redirect to that RewriteRule. Change [L] to [R,L].

That'll start a redirect loop, though. You'll likely want to change it to not match index.php.

4
  • Hey, many thanks for the response. Sorry about the late reply - I fell asleep! How would I change it to not match index.php?
    – Eamorr
    Sep 8, 2011 at 8:22
  • Hey, when I changed it to [R,L] and go to example.com/Eamorr, I get example.com/home/eamorr/sites/example.com/www/… in the address bar. It's as if it goes to the document root!
    – Eamorr
    Sep 8, 2011 at 8:31
  • @Eamorr Hmm, relative path funkiness. Change your redirect to have the full URL; http://www.example.com/index.php?uname=$1. Sep 8, 2011 at 14:32
  • It works! Thanks so much! You are my hero for the day!
    – Eamorr
    Sep 8, 2011 at 14:36

Not the answer you're looking for? Browse other questions tagged .