Question

How to config for fix

When i enter website in url https://example.com/. i can enter website. but i enter website in url example.com/ Webpage showing error.

 Forbidden
 You don't have permission to access this resource.
 
 Apache/2.4.41 (Ubuntu) Server at example.com Port 80

I check log

sudo tail -100 /var/log/apache2/error.log

This is result

[Wed Jul 20 07:18:22.838769 2022] [rewrite:error] [pid 234347] [client 49.228.236.32:37690] AH00670: Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive is also forbidden due to its similar ability to circumvent directory restrictions : /var/www/example/

I fix in apache2.conf and .htaccess

<VirtualHost *:80>
<Directory /usr/share>
	AllowOverride All
	Require all granted
</Directory>

<Directory /var/www>
        Options +SymLinksIfOwnerMatch
        AllowOverride All
        Order deny,allow
        Allow from all
</Directory>

#<Directory /srv>
#	Options Indexes FollowSymLinks
#	AllowOverride All
#	Require all granted
#</Directory>
</VirtualHost>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Bug can not fix issue


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
July 21, 2022

Hello,

As your HTTPS version is working as expected, what I could suggest is to add a redirect from HTTP to HTTPS so that the users would be redirected to the correct version rather than seeing the 403 error.

You can do that by adding the following to your Apache virtual host for port 80:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

Hope that this helps!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.