I am struggling to get the rewrite rules working in .htaccess for search links on a property rental website I am working on.
The old links are like this:
example.com/index.php?proptype=Villa&action=search
and the new search link equivalent will be like this:
example.com/listing?holidaytype=Villa
Before I tried with wildcards I wanted to test with a set parameter. I have tried both of the following approaches but neither works.
RewriteRule index.php?proptype=Villa&action=search listing?holidaytype=Villa [L]
RewriteCond %{QUERY_STRING} ^proptype=Villa&action=search$
RewriteRule ^index.php listing?holidaytype=Villa [L]
The only lines above these in my .htaccess file are as follows:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Having checked a number of other related questions here and on other rewrite guidelines, I still can't get the rules working. What have I missed - or could it be another problem?
Graham
/listing?holidaytype=Villa
- A URL like this is unlikely to map directly to the filesystem so there must be some other processing going on here? Does this map tolisting.php
perhaps?/listing?...
does seem to open listing.php - or possibly another file with handles the parameters first.Villa
a dynamic string that should be copied from the old URL to the new?