1

I got a .htaccess issue, and I don't know why, because it should be working.

What I'm trying to do with this code is redirect https://www.sub.domain.com to https://sub.domain.com

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.sub\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://sub.domain.com/$1 [L,R=301]

When I test this code at http://htaccess.madewithlove.be/, it works succesfully.

(Request url: https://www.sub.domain.com, output url: https://sub.domain.com)

Also as mentioned in this question, I checked my DNS records , and there is an www.sub which points to the some domain as sub (both A's).

At this point I'm stuck, does anyone know what I did wrong? Any help would be appreciated.

Community
  • 1
  • 1
JiFus
  • 959
  • 7
  • 19
  • Your code is fine. Make sure `VirtualHost` block for ssl is correct (document root and htaccess enabled) – Justin Iurman Jan 04 '15 at 11:24
  • Thanks for your comment, I know for sure htaccess is enabled. When I try something else like: `RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://sub.domain.com/$1 [R,L]` in my public_html, to send every request over ssl, it works correctly. – JiFus Jan 04 '15 at 11:26
  • Could you update your question with VirtualHost blocks (port 80 and 443) ? – Justin Iurman Jan 04 '15 at 11:26
  • Where can I find these? Sorry, but I'm a total noob at htaccess – JiFus Jan 04 '15 at 11:31
  • In your apache configuration file – Justin Iurman Jan 04 '15 at 11:32
  • And where can I find this configuration file? I've searched for 5 minutes but can't find it.. – JiFus Jan 04 '15 at 11:39
  • It depends, but most of the time it can be found at `/etc/apache2/apache2.conf` (you can see this question to see how to find it: http://stackoverflow.com/questions/12202021/where-is-my-httpd-conf-file-located-apache ) – Justin Iurman Jan 04 '15 at 11:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/68167/discussion-between-jifus-and-justin-iurman). – JiFus Jan 04 '15 at 11:53

1 Answers1

-2

Create a file called .htaccess in the doc root (web / httpdocs / www folder) of https://www.sub.domain.com and put in the code below

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://sub.domain.com/$1 [R=301,L]