[Techtalk] Moving Websites: 301 Redirect

Sheila Fenelon sheila at shefen.com
Sun Jun 6 19:12:57 UTC 2010


Sue Stones wrote:
> 
> I am still to get page redirects to work.  I am not sure what I am
> trying to match,
> Does HTTP_HOST match the whole URL or just the domain name?  HTTP_URI
> apparently matches more than I want.
> 

HTTP_HOST is the domain plus the port number if it's not 80, in other
words everything between http://  and the first single / .
HTTP_URI would be everything from the first single slash up to the any #
used to mark an anchor. It includes the leading / .

For example,
http://localhost:8082/info.php?p=1#anchor

HTTPHOST = localhost:8092
HTTP_URI = index.php?p=1

Are you familiar with phpinfo()? You can see these values in the
$_SERVER variables. Again, Apache will never see the anchor (#) or the
anchor name that follows it.


Sheila


>> Sue Stones wrote:
>>  
>>> A simple rewrite that works is
>>>
>>> RewriteRule ^(.*)$ http://www.redcockatooaustralia.com/ [L,R=301]
>>>
>>> But when I try to duplicate this approach with something like the
>>> following not much happens
>>>
>>> RewriteRule ^(.*)/artists\.php\#artsec$
>>> http://www.redcockatooaustralia.com/artists/elly-chatfield/$ [L,R=301]
>>>
>>>
>>>     
>>
>> Clicking on an anchor like #artsec is handled by the browser. They don't
>> result in a request being send back to the server, so your RewriteRule
>> will never be invoked.
>>
>> Sheila
>>



More information about the Techtalk mailing list