Redirect from base directory

Hi

I am having difficulty making this work, and I have tried hard over the past 24 hrs.

I have http://localhost/my-property/?p=1 which I need to redirect to http://localhost/my-property/index.html?p=1.

Simples!! Well not for me I am afraid.

My ht_access file contains the following:

Options +FollowSymLinks All -Indexes

RewriteEngine on

RewriteRule ^/p=([0-9]+)$   /my-property/index.html?p=$1 [L,R=301]

RewriteRule index([0-9]+)\\.html$  index.html [L,R=301]

RewriteRule list-page([0-9]+)\\.html$ /my-property/index.html?p=$1 [L,R=301]

RewriteRule ^(.*)\\.html $1.php [L]

The first line is the one that is causing me grief, the others work just fine, andthis is the final attempt of many with and without a rewrite cond.

I hope somebody can point out just where I am going wrong, I have trawled the pages of this site but still cannot find a solution.

TIA

Colin

Hi Colin!

I can see why the first line has a problem - and you should be able to see it, too! Because the RewriteRule can ONLY examine the {REQUEST_URI} string (which does NOT contain the {QUERY_STRING}), any attempt to access it (or the {HTTP_HOST} or other Apache variables) is doomed to failure.

My ht_access file contains the following:

Hmmm, that’s the .htaccess file! No filename, just the htaccess file extension.

Options +FollowSymLinks All -Indexes

RewriteEngine on

RewriteRule ^/p=([0-9]+)$   /my-property/index.html?p=$1 [L,R=301]
# the ^/ will ONLY match on an Apache 1.x server
# p=(\\d+) is obviously the query string
# use RewriteCond %{QUERY_STRING} p=(\\d+) to capture the numeric value of p
# followed by RewriteRule index\\.php$ my-property/index.html?p=%1 [R=301,L]

RewriteRule index([0-9]+)\\.html$  index.html [L,R=301]
# Strips digits off index#.html

RewriteRule list-page([0-9]+)\\.html$ /my-property/index.html?p=$1 [L,R=301]
# captures digits appended to list-page#.html and sends then as the
# value of p to my-property/index.html in the new/replacement query
# string

RewriteRule ^(.*)\\.html $1.php [L]
# redirects EVERY .html file to its .php equivalent

Regards,

DK