Re: Rewrite Rules, SSL, and .htaccess
From: davec (davec_at_webpipe.net)
Date: 04/02/04
- Previous message: cookie: "Re: iptables firewall script for debian-woody, 2.4.24"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
To: jm@gblx.net Date: Fri, 02 Apr 2004 00:47:46 -0700
> davec wrote the following on 03/28/04 18:31:
>>> RewriteEngine on
>>> RewriteBase /usr/local/website
>>> RewriteCond %{SERVER_PORT} !^443$
>>> RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
>>
>>
>> This seems to work for all cases except when I enter www.mydomain.com/dir
>> without the final trailing slash, and then I get a 404 error. I did a
>> little more research and found a rule that seems to work (inside the
>> Directory tag) only for that special case:
>> RewriteRule ^$ https://%{SERVER_NAME}/dir/ [L,R]
>> The rule only works when it is by itself. I tried to combine them like
>> this:
>> RewriteRule ^$ https://%{SERVER_NAME}/dir/ [L,R]
>> RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
>> Then I get the same 404 error as before when I leave out the trailing
>> slash. How can I get both of these rules to work together?
>> Thanks,
>> Dave
>
> ahh.. the "trailing slash" problem with Apache..
>
> <URL:
> http://www.onlamp.com/pub/a/apache/2004/02/19/apache_ckbk.html?page=2>
>
> a quote from the above article:
> "The "trailing slash" problem can be caused by one of two configuration
> problems: an incorrect or missing value of ServerName, or an Alias with a
> trailing slash that doesn't work without it."
The link above did not seem to solve the problem. After searching a little
more I found the following RewriteRule combination that seems to fix the
problem:
RewriteRule ^/usr/local/website/dir$ ""
RewriteRule ^(.*) https://%{SERVER_NAME}/dir/$1 [L,R]
The apache log showed the following string when I accessed the link without
the trailing slash, "dir//usr/local/website/dir" so I had to strip out the
"/usr/local/website/dir" to get back to the correct directory location
relative to the web root.
Thanks for all the help and responses.
Dave
- Previous message: cookie: "Re: iptables firewall script for debian-woody, 2.4.24"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|