Hi Guys,
I'm experimenting with Apache's mod_rewrite module. It's pretty neat, but I'm having a couple of problems that I haven't been able to work out, so I hope someone here will be able to help me out?
My current rule looks roughly like this:
Code:
RewriteRule ^(.*)/?$ page.php?show=$1 [L]
This takes urls that look like
www.example.com/somepage.php and rewrites them as
www.example.com/page.php?show=somepage.php. My page.php script then works out what to do with them from there.
That much is working fine.
The first problem I've got is if I try to access the site's default page - ie I enter
www.example.com, but without adding index.php or anything to the end.
In this case, the rewrite rule doesn't seem to get run at all, and since I don't have a page called index, I end up getting a 410 error.
What I would like is for it to rewrite it to
www.example.com/page.php?show= (The page.php program will work out what to do if show isn't set). If anyone can explain why the rule isn't being run in this case, and how to make it work, I'd be very grateful. Thanks
The second problem is that some of the pages on the site need to be able to accept values from a form, so I need to be able to support GET request variables - eg
www.example.com/search.php?q=planes&p=2.
The idea being that this would then be rewritten as
www.example.com/page.php?page=search.php&q=planes&p=2.
Sadly, though, the request variables don't seem to be passed through rewrite. Please can someone tell me how to GET them. (pun intended)
Many thanks in advance for any help you can give.
All the best,
Spudley.