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,

Eamorr
  • 596
  • 5
  • 13
  • 27

1 Answers1

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.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • 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 08 '11 at 08:22
  • Hey, when I changed it to [R,L] and go to http://example.com/Eamorr, I get http://example.com/home/eamorr/sites/example.com/www/index.php?uname=Eamorr in the address bar. It's as if it goes to the document root! – Eamorr Sep 08 '11 at 08:31
  • @Eamorr Hmm, relative path funkiness. Change your redirect to have the full URL; `http://www.example.com/index.php?uname=$1`. – Shane Madden Sep 08 '11 at 14:32
  • It works! Thanks so much! You are my hero for the day! – Eamorr Sep 08 '11 at 14:36