.htaccess redirect to subfolder with https://www

Author Topic: .htaccess redirect to subfolder with https://www  (Read 149 times)

Offline mahisharma2Topic starter

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 3
  • Karma: 0


    Hi everyone,

    So I'm having this website which is stored inside public_html/www/. Some other domains are stored in -for example- public_html/test/. In public_html I have a .htaccess file with a LOT of redirects in it, which all apply to this website inside /www/ folder. Inside the /www/ folder I have another .htaccess (I don't really know why, my colleague did this and he left me with this without information). Since I have no idea how .htaccess exactly works, I have no idea what to do and in which file.

    What I need to do is to redirect domain.nl to https://www.domain.nl (some folders should be excluded, like you can see in the code below - emailtemplates, paymentupdate, autocode, nieuwsbrieven, etc.) But domain.nl is stored inside public_html/www/ folder, so it also needs a redirect to the subfolder (which should not be visible in web browser).

    At this moment, in the root .htaccess file is the following:

    # Use HTTPS
    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.nl [NC]
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} !^/emailtemplates
    RewriteCond %{REQUEST_URI} !^/paymentupdate_ideal
    RewriteCond %{REQUEST_URI} !^/autocode
    RewriteCond %{REQUEST_URI} !^/nieuwsbrieven
    RewriteCond %{REQUEST_URI} !^/bevestig-aanmelding-nieuwsbrief
    RewriteCond %{REQUEST_URI} !^/bevestig-afspraak
    RewriteCond %{REQUEST_URI} !^/images/personal
    RewriteCond %{REQUEST_URI} !^/uploadify
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Link to subfolder
    # RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www.)?www.domain.nl$
    RewriteCond %{REQUEST_URI} !^/www/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /www/$1
    RewriteCond %{HTTP_HOST} ^(www.)?www.domain.nl$
    RewriteRule ^(/)?$ www/index.php?page=home [L]

    # Non-www to www
    #activate rewrite engine
    #RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?domain.nl
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    Probably half of this code isn't even necessary, but I have absolutely no clue. The other .htaccess file, within the subfolder /www/, has the following text which I don't really understand (it contains more, but nothing relevant):

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.domain.nl/$1/ [L,R=301]
    I'm sorry if I sound stupid. I've tried many things copied from internet, but unfortunately everything has its concequences, which results in other problems with our website (links that don't work anymore, such as). I think the reason it doesn't work all the time, is because it's stored in the subfolder and I don't know how to combine all those lines in one like it would work.

    Can anybody help me explain how to fix this and what is going wrong at this moment? Because the website is now not redirecting to www. It's just redirecting to https which gives me a security error at this moment (because the SSL is stored on www.). SUPER thanks in advance!



 

Related Topics

  Subject / Started by Replies Last post
0 Replies
903 Views
Last post 12-13-2013, 12:37:34
by jpf566
2 Replies
1084 Views
Last post 12-04-2014, 02:47:16
by Stephen
0 Replies
1120 Views
Last post 04-25-2015, 23:00:10
by immediate
0 Replies
485 Views
Last post 04-27-2015, 17:09:57
by nqservices
3 Replies
374 Views
Last post 12-05-2016, 02:10:42
by jamespatrick2512