user1038814
user1038814

Reputation: 9677

.htaccess URL rewrite with one and two query string vars

I'm trying URL re-writing for the first time and I have the following URLS which need rewriting:

http://domain.com/resorts.php?countryname=Portugal
http://domain.com/rss.php?destination=Torremolinos&itemtype=rfamily

I've written the following in my .htaccess file:

Options +FollowSymLinks
RewriteEngine on

RewriteRule /countryname/(.*)/ resorts.php?countryname=$1
RewriteRule /destination/(.*)/itemtype/(.*)/ rss.php?destination=$1&itemtype=$2

But when I try the following, I keep getting URL not found. Please can someone point out what I may be doing wrong? Many thanks in advance.

http://domain.com/countryname/Portugal
http://domain.com/destination/Torremolinos/itemtype/rfamily

Upvotes: 3

Views: 2954

Answers (1)

Book Of Zeus
Book Of Zeus

Reputation: 49885

You can use this:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule countryname/(.*)/? resorts.php?countryname=$1 [NC,L]
RewriteRule destination/(.*)/itemtype/(.*)/? rss.php?destination=$1&itemtype=$2 [NC,L]

Upvotes: 3

Related Questions