cancel
Showing results for 
Search instead for 
Did you mean: 

Apache URL Redirect

SOLVED
Go to solution
ManojK_1
Valued Contributor

Apache URL Redirect

Hi,

I want to re direct the requestes which are coming to my server url to https://server/test.

It is working fine if i am giving http://server (http://server redirecting to https://server/test).This is achived by adding the following lines in httpd.conf.

RewriteEngine on
RewriteRule ^/$ https://server/test [R]

But if am giving https://server it is not rdirecting to https://server/test. How i can achive this?

Manoj K
Thanks and Regards,
Manoj K
2 REPLIES
Matti_Kurkela
Honored Contributor
Solution

Re: Apache URL Redirect

There are many possible ways to structure your Apache configuration file.

If the same Apache instance offers both http and https services, one possible way to configure it is to have a separate VirtualHost block for one service (either http or https), and let the main server configuration cover the other service.

Another way is to have two VirtualHost blocks, one explicitly for http and the other for https.

So you may have to add your redirect definition to another spot in your configuration to make it take effect for the HTTPS service too. But without knowing how your Apache configuration is structured, I cannot tell you exactly where to put it.


By the way, using the RewriteEngine for such a simple redirect is probably overkill. A simpler way to redirect all requests for the server's front page to https://server/test would be:

RedirectMatch ^/$ https://server/test

If someone requests e.g. http://server/foo and you'll want it automatically redirected to https://server/test/foo instead, then:

RedirectMatch ^/(.*)$ https://server/test/$1

MK
MK
ManojK_1
Valued Contributor

Re: Apache URL Redirect

Hi Matti,

Thanks for your support.

I have append the following line in httpd.conf

RedirectMatch ^/$ https://server/test

and it is solved the issue.

Manoj K
Thanks and Regards,
Manoj K