views:

22

answers:

1

Here's what I want to do:

http://www.mysite.com/      >    http://www.mysite.com/index.php
http://www.mysite.com/asd   >    http://www.mysite.com/index.php?page=$1

asd will be the name of the page(s) that get appended to index.php's $page variable.

My current rewrite rule successfully redirects the requested page but fails to load the default index.php page.

RewriteEngine On
RewriteRule ^([\w]*)$ /index.php?page=$1 [L]

How do I fix this? :/

+1  A: 

You would need to have one rule that matches just the /:

RewriteRule ^/$ /index.php [L]

And then your other one:

RewriteRule ^/([\w]+)$ /index.php?page=$1 [L]
Ben Smith
Isn't `[\w]` redundant? I think `\w` is enough.
Amarghosh
I would say it was redundant. I find that RewriteRules have a tendency to not work in unexpected ways, so I left it in.
Ben Smith