Help with Apache mod_rewrite?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Help with Apache mod_rewrite?

Post by Kadanis »

I'm trying to set up a couple of rewrite rules, but I'm struggling to get them both to work. One works fine, but the other fails. Just wondered if anyone with maybe a bit more experience with this could lend a hand.

The URL I want to use is

http://www.domain.tld/page/action.html => http://www.domain.tld/index.php?page=page&action=action

or

http://www.domain.tld/page/action.html?foo=bar&x=y => http://www.domain.tld/index.php?page=pa ... oo=bar&x=y
(with any number of additional query string components)

Here is my .htaccess

Code: Select all

 
RewriteEngine On
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)\.html\?(.*)$ /index.php?page=$1&action=$2&$3 [L]
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)\.html$ /index.php?page=$1&action=$2
 
Now it routes the first type of URL fine, but fails to route the second type, so I can't seem to get anything off the URL except for the page and action.

Can anyone help out?
Cheers
Post Reply