Jump to content

[Solved] Any .htaccess rewrite will causes error 403


yky123

Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...