Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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,

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
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 '11 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 '11 at 8: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 8 '11 at 14:32
    
It works! Thanks so much! You are my hero for the day! –  Eamorr Sep 8 '11 at 14:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.