I have the following in my .htaccess file:

<Directory /home/eamorr/sites/example.com/www>
                Options Indexes FollowSymLinks MultiViews
                Options -Indexes
                AllowOverride all
                Order allow,deny
                allow from all

                RewriteEngine on
                RewriteRule ^([^/.]+)/?$ index.php?uname=$1 [R,L]
</Directory>

When I go to http://example.com/Eamorr, http://example.com/home/eamorr/sites/example.com/www/index.php?uname=Eamorr appears in the address bar!

But I want http://example.com/index.php?uname=Eamorr to appear in the address bar!!!

(I need to parse the URL in javascript in index.php)

link|improve this question

59% accept rate
feedback

1 Answer

up vote 1 down vote accepted

<Directory> directive can be only used in server config or virtual host, not in .htaccess file.

If you use:

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

the per-directory prefix (/home/eamorr/sites/example.com/www) is automatically added to the substitution. So remove the <Directory> directive and put a slash at the begining:

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

it will work as you expect.

link|improve this answer
Thanks so much for that. I'm totally clueless when it comes to anything other than bog standard Apache rules... – Eamorr Sep 8 '11 at 15:19
feedback

Your Answer

 
or
required, but never shown

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