Answer the question
In order to leave comments, you need to log in
403 error in apache?
Good night, friends
I can not understand what the problem is. I get a 403 error when trying to access the site using the example.com url , when everything works fine from www.example.com .
There is a DirectoryIndex index.php directive in http.conf.
Error text "You don't have permission to access / on this server."
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# redirect without www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# redirect from index.html, index.htm to root
RewriteRule ^(.*)index\.(html?)$ /$1 [R=301,NC,L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
# otherwise forward it to index.php
RewriteRule . index.php
# redirect from index.php to root(for yii)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?)index\.php([^\s]*) [NC]
RewriteRule ^ /%1%2 [R=301,L,NE]
# redirect without trailing last slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
# redirect with trailing last slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^\.localhost$ [NC]
RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L]
Answer the question
In order to leave comments, you need to log in
Are you sure that you have everything rewritten correctly?
stackoverflow.com/questions/9632852/how-to-debug-a...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question