Zak
Zak

Reputation: 7525

htaccess directive conflicting with https -- 404 not found

I have a simple problem (I think).

What my website does correctly -- The URL http://example.com/mypage uses -> /var/ww/html/mypage.php | Put simply, it essentially allows removal of the php extension from the URL.

What my intended result is to do the same thing with https. However I am returning a 404. So my rewrite condition isn't functioning correctly for https, but is functioning correctly for http.

Here is the .htaccess file:

RewriteEngine On

Options -MultiViews

RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

With this setup, do I have to specify %{HTTPS} ?? Is there something else I am missing?

Upvotes: 0

Views: 82

Answers (1)

Lanee Barman
Lanee Barman

Reputation: 113

Try to add this two line after "RewriteEngine On"

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]]

Hopefully it works. Though this will replace http:// with https://

Upvotes: 1

Related Questions