Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

http redirection to httpd

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


cfmx07 at yahoo

Nov 5, 2009, 1:45 PM

Post #1 of 4 (127 views)
Permalink
http redirection to httpd

Hi,

I have two webpages...

1. www.mypage.com and
2. www.mypage.com/private

The issue that I am having is, I need to redirect all http requests coming
to http://www.mypage.com/private to https://www.mypage.com

However, I don't want the requests coming to http://www.mypage.com to be
redirected to https://www.mypage.com.


How do I accomplish it ?

I will highly appreciate your suggestions..Thanks..
--
View this message in context: http://old.nabble.com/http-redirection-to-httpd-tp26222774p26222774.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


johnlist at gulfbridge

Nov 5, 2009, 2:22 PM

Post #2 of 4 (117 views)
Permalink
Re: http redirection to httpd [In reply to]

sangfroid wrote:
> Hi,
>
> I have two webpages...
>
> 1. www.mypage.com and
> 2. www.mypage.com/private
>
> The issue that I am having is, I need to redirect all http requests coming
> to http://www.mypage.com/private to https://www.mypage.com
>
> However, I don't want the requests coming to http://www.mypage.com to be
> redirected to https://www.mypage.com.
>
>
> How do I accomplish it ?
>
> I will highly appreciate your suggestions..Thanks..
>

Simplest solution is the Redirect directive:
From http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect :

The Redirect directive maps an old URL into a new one by asking the
client to refetch the resource at the new location.

The old /URL-path/ is a case-sensitive (%-decoded) path beginning
with a slash. A relative path is not allowed. The new /URL/ should
be an absolute URL beginning with a scheme and hostname.


Example:

| Redirect /service http://foo2.bar.com/service |

If the client requests |http://myserver/service/foo.txt|, it will be
told to access |http://foo2.bar.com/service/foo.txt| instead.

So in your case you would use something like:

| Redirect /private https://foo2.bar.com/
|

|
|

John


cfmx07 at yahoo

Nov 5, 2009, 3:04 PM

Post #3 of 4 (117 views)
Permalink
Re: http redirection to httpd [In reply to]

Hi John,

Thank you for the reply. I also found one more way to do it ...

Added the following directive in httpd.conf


<Location /private>
RewriteEngine On
ReWriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}:443%{REQUEST_URI} [QSA,R=permanent,L]
</Location>

However, now the problem is, I also needed the users to authenticate by
htaccess file. But keeping .htaccess file in /var/www/html/private is not
working. I mean in that case, first the system asks password in an unsecured
mechanism and then only https redirection is working. I wanted just the
reverse...first establish secure connection and then only ask the user for
password...

Any clue on it ??





John Hicks wrote:
>
> sangfroid wrote:
>> Hi,
>>
>> I have two webpages...
>>
>> 1. www.mypage.com and
>> 2. www.mypage.com/private
>>
>> The issue that I am having is, I need to redirect all http requests
>> coming
>> to http://www.mypage.com/private to https://www.mypage.com
>>
>> However, I don't want the requests coming to http://www.mypage.com to be
>> redirected to https://www.mypage.com.
>>
>>
>> How do I accomplish it ?
>>
>> I will highly appreciate your suggestions..Thanks..
>>
>
> Simplest solution is the Redirect directive:
> From http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect :
>
> The Redirect directive maps an old URL into a new one by asking the
> client to refetch the resource at the new location.
>
> The old /URL-path/ is a case-sensitive (%-decoded) path beginning
> with a slash. A relative path is not allowed. The new /URL/ should
> be an absolute URL beginning with a scheme and hostname.
>
>
> Example:
>
> | Redirect /service http://foo2.bar.com/service |
>
> If the client requests |http://myserver/service/foo.txt|, it will be
> told to access |http://foo2.bar.com/service/foo.txt| instead.
>
> So in your case you would use something like:
>
> | Redirect /private https://foo2.bar.com/
> |
>
> |
> |
>
> John
>
>

--
View this message in context: http://old.nabble.com/http-redirection-to-httpd-tp26222774p26223880.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


aw at ice-sa

Nov 5, 2009, 4:23 PM

Post #4 of 4 (114 views)
Permalink
Re: http redirection to httpd [In reply to]

sangfroid wrote:
> Hi John,
>
> Thank you for the reply. I also found one more way to do it ...
>
> Added the following directive in httpd.conf
>
>
> <Location /private>
> RewriteEngine On
> ReWriteCond %{HTTPS} !=on
> RewriteRule .* https://%{HTTP_HOST}:443%{REQUEST_URI} [QSA,R=permanent,L]
> </Location>
>
> However, now the problem is, I also needed the users to authenticate by
> htaccess file. But keeping .htaccess file in /var/www/html/private is not
> working. I mean in that case, first the system asks password in an unsecured
> mechanism and then only https redirection is working. I wanted just the
> reverse...first establish secure connection and then only ask the user for
> password...
>
> Any clue on it ??
>
Then you will probably have to create 2 VirtualHost, and place your
authentication in the HTTPS host.

Listen *:80
Listen *:443
...
<VirtualHost *:80>
your HTTP host config
</VirtualHost>
<VirtualHost *:443>
your HTTPS host config

<Location />
AuthType Basic
AuthName private
...
</Location>

</VirtualHost>

---------------------------------------------------------------------
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[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.