-1

I have a website based on WordPress, and one section of it is built by external programmers (the backend). I was able to force all connections to go on HTTPS instead of HTTP using a plugin for the WordPress part, but for this specific area which isn't WordPress-based I had to do something else. My knowledge is restricted so I just googled it and found I should create an .htaccess file inside the specific folder with the following:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} folder 
RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]

I did just that, and now when I'm trying to access that area, it says it doesn't exist (404 error):

The requested URL /backend/auth/login was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

The weird thing is, when I try to access directly the link The requested URL /backend/index.php, it does work and redirects me to:

/backend/index.php/auth/login

I don't know how to fix it or what to do but actually I don't see an "auth" folder in there, but it works under index.php

In addition, when trying to reverse what I did, I deleted the .htaccess file, but it still isn't working, which is really weird.

Any ideas?... Thanks!

user341879
  • 1
  • 1
  • 1
  • 2
    Possible duplicate of [Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About Mod\_Rewrite Rules but Were Afraid to Ask](http://serverfault.com/questions/214512/redirect-change-urls-or-redirect-http-to-https-in-apache-everything-you-ever) – MadHatter Mar 08 '16 at 08:10
  • @MadHatter I have to disagree with your duplicate vote, because I don't think `mod_rewrite` is a good way to redirect from HTTP to HTTPS. Instead I would recommend using an HTTP-only vhost with a single `Redirect` directive. – kasperd Mar 11 '16 at 10:29
  • @kasperd you are of course free to do so, but given that the linked possible duplicate is (a) a canonical question and (b) about (*inter alia*) that very issue, I think you should add a new answer to the canonical question, making your case that mod_rewrite is not a good way to do this, and showing your preferred way. I'd upvote it if you did. – MadHatter Mar 11 '16 at 10:33
  • @MadHatter That canonical question is about `mod_rewrite`, so an answer explaining how to redirect from HTTP to HTTPS without using `mod_rewrite` would seem inappropriate to me. One could argue that the canonical question is too broad. I think the question about how to redirect from HTTP to HTTPS in Apache deserves its own canonical question. Perhaps we can find an existing question to promote to a canonical question. Links between the two would seem like a good idea. – kasperd Mar 11 '16 at 10:44
  • 1
    @kasperd actually, the main title is "Redirect, Change URLs or Redirect HTTP to HTTPS in Apache" - the mod_rewrite bit is mentioned in the subsidiary title. But I take your point; another question might be better. Why not take the issue to meta? I still think you're best placed to write the answer, because you are the one who thinks that mod_rewrite isn't the right way to do it! – MadHatter Mar 11 '16 at 11:11

1 Answers1

0

Which folder did you put the htaccess file in? If you've nested wordpress inside of a top folder, you might have two. For instance, I have my wwwroot folder and then a set of subdomain folders on a server like so:

/ (wwwroot)

/sub1 - wordpress install 1

/sub2 - wordpress install 2

/sub3 - wordpress install 3

Each subfolder has its own set of .htaccess of 400/401/403/404/500 files (automatically, because wordpress).

This allows for server-wide htaccess rules to go into a single file (in wwwroot, such as security rules) and then the site-specific ones (redirects, etc) to go into each wordpress folder as necessary. It also allows for isolating each wordpress install so they don't affect each other. Keep in mind that the root htaccess should only have rules that you want to apply to all of the subfolders.

Kinna T
  • 101
  • 2