Oliver Schael
Oliver Schael

Reputation: 35

.htaccess not working on SSL apache

Trying to fix this .htaccess, so it can work on a SSL apache server. Before it was hosted on another Linux server (http://) and was working without problems, but when uploading the files to another Linux server with apache and SSL (https://), it stopped working. The main function is to hide the .php extension...

Here´s what I was using:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]

Thanks for your help!

Upvotes: 2

Views: 3248

Answers (3)

Paras Nakum
Paras Nakum

Reputation: 230

Solution is for the issue, need to change in apache2.conf file after that it will works,

Change this file /etc/apache2/apache2.conf update it same

OLD: <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>

New Updated Code: <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>

enter image description here

Upvotes: 1

mYmage
mYmage

Reputation: 92

I had a similar problem. Apache 2.4.23 with .htaccess error 404 set up. Using it with HTTP works fine; access it with HTTPS didn't work. I seted AllowOverride All in the http.conf and error 404 wors well.

Upvotes: 0

Brian Gottier
Brian Gottier

Reputation: 4582

So, .htaccess files may not be allowed, and by default on many systems they are not allowed. To see if .htaccess is allowed, make this your .htaccess:

BREAK IT!

That should be the only contents in your .htaccess. Attempt to load any page on your website, and if .htaccess usage is enabled, you would see "Internal Server Error" or possibly some other error, but you would not see your actual page.

If you do see the error, that's actually good and means .htaccess usage is enabled. If you don't see the error, it's likely that you will have to find your Apache .conf file and inside look for the line(s):

AllowOverride None

Change that to:

AllowOverride All

If after doing that you still can't use .htaccess, then there may be other apache related files that have "AllowOverride None". On that comes to mind is your virtual host file, and on my system that is located at /etc/apache2/sites-available/.

If you still have problems, check this out: https://docs.bolt.cm/3.3/howto/making-sure-htaccess-works

Upvotes: 4

Related Questions