Re: Using .htaccess to force rewriting URLs to https:// works but loses any subdirectory paths. What do I need to change?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use HTTP_HOST instead SERVER_NAME

RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [R,L]

The SERVER_NAME is the variable you set up in the httpd.conf file
where HTTP_HOST is the variable from the client request.

On 6/16/09, Justin Pasher <justinp@xxxxxxxxxxxxxxxxxxx> wrote:
> Bob Linkonij wrote:
>> Ok, so I changed
>>
>>    RewriteCond %{HTTPS} !=on
>> -  RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}/$1 [R,L]
>> +   RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
>>
>> in the .htaccess file.
>>
>> But still when I go to
>>
>>   http://Domain.com/subdirectory
>>
>> I get redirected to
>>
>>   https://Domain.com
>>
>
> Hmmm... I'm not seeing anything obvious (this is the same type of code I
> use to redirect URLs on my servers, albeit based upon the host name
> provider, not HTTP vs HTTPS). I normally set this kind of thins inside
> the apache conf (in the VirtualHost container) because rewrite rules
> work slightly different in apache conf vs .htaccess, but it shouldn't be
> affecting this situation.
>
> A couple of things to try:
>
> 1) Change the RewriteRule to this (just to make sure it's really
> processing and matching it)
>
> RewriteRule (.*) https://%{SERVER_NAME}/this-page-is-bad [R,L]
>
> 2) Try cranking up the RewriteLogLevel a bit to see the rewrites in
> action, once again to make sure it's processing properly.
>
> 3) Make sure you clear your browser cache. I've seen odd instances where
> a browser might cache a redirect.
>
>
> --
> Justin Pasher
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux