Jump to content

Recommended Posts

Posted

It seems any .htaccess rewrite will cause error 403 when accessing my webpage and no redirects, I try to redirect http to https and set up a Django-based website by modifying .htaccess.

 

for redirect http to https,I try something like this:

which is most of the answers from https://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https

RewriteEngine On


RewriteCond %{HTTPS} !on
~or~
RewriteCond %{HTTPS} !=on
~or~
RewriteCond %{HTTPS} off


RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
~or~
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
~or~
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
~or~
RewriteCond %{HTTPS_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

PS:www.example.com is replaced by my real url(with and without www)

 

for setup a Django-based website,i follow all steps in https://wiki.helionet.org/Django , which

 

modify .htaccess like this:

RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(hello/dispatch\.wsgi/.*)$ - [L]
RewriteRule ^(.*)$ hello/hello/dispatch.wsgi/$1 [QSA,PT,L]

===================

parts of error log:

[Fri Mar 22 06:24:58.676083 2019] [rewrite:error] [pid 32763] [client IP:Port] AH00670: Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive is also forbidden due to its similar ability to circumvent directory restrictions : /home/username/public_html/403.shtml

===================

the 403 page:

Forbidden

You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Posted

Is your website on WordPress? If so there is an easy way out. Install'Really Simple SSL' and all traffic will be redirected to https.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...