1

I have a domain foo.com running on apache 2.2 with SSL. Any time someone types the following in the browser:

- foo.com
- http://foo.com
- www.foo.com
- https://foo.com

I want it all to get redirected to: https://www.foo.com/bar/index.xhtml

I've tried the suggestions from the Apache site:

RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R]

but they are not working. I would be happy just to get the rewrite rule for the scenarios I listed; not everything.

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
zoroloco
  • 51
  • 3
  • So, what have you tried (from the Apache site)? We might very well come up with the same thing, so there could be something fundamentally wrong with your config, but we don't know until we see what you've tried. And when you say "not working" - what do you mean _exactly_? Does _anything_ happen? Do you get an error? – MrWhite Aug 07 '15 at 20:56
  • I believe [this answer](https://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www/13997498#13997498) should address all your use cases, except to use `bar/index.xhtml` instead of `REQUEST_URI. – Michael Berkowski Aug 09 '15 at 22:21

0 Answers0