21

Index file exists and works. When I create .htaccess file with the ONLY line:

RewriteEngine On 

Any page on server gives me:

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster. Error 403 mysite.com Wed Oct 5 22:25:25 2011 Apache/2.2.3 (Linux/SUSE)

Some server info:

Loaded Modules core prefork http_core mod_so mod_actions mod_alias mod_auth_basic mod_authn_file mod_authz_host mod_authz_groupfile mod_authz_default mod_authz_user mod_authn_dbm mod_autoindex mod_cgi mod_dir mod_env mod_expires mod_include mod_log_config mod_mime mod_negotiation mod_setenvif mod_ssl mod_suexec mod_userdir mod_rewrite mod_php5

Apache version:

SERVER_SOFTWARE Apache/2.2.3 (Linux/SUSE)

Also did this:

Options FollowSymLinks

In Directory section of httpd.conf

Log says just fact of error, not reasons:

89.112.xx.x - - [05/Oct/2011:22:32:34 +0200] "GET /info.php HTTP/1.1" 403 1040 "-" "Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
::1 - - [05/Oct/2011:22:32:45 +0200] "GET / HTTP/1.0" 200 1 "-" "Apache/2.2.3 (Linux/SUSE) (internal dummy connection)"

Thanks for any help!

Dmitry
  • 3,861
  • 5
  • 20
  • 21
  • Please check below link. It will help you http://stackoverflow.com/questions/22621643/turning-rewriteengine-on-creates-403-error-how-to-turn-on-followsymlinks#answer-22623427 – NIMESH PAREKH May 08 '15 at 04:43

4 Answers4

44

Place

Options +SymLinksIfOwnerMatch

as the first line of your .htaccess file. That fixed the problem for me.

Kurt
  • 536
  • 4
  • 5
  • 5
    `+FollowSymLinks` is required for the rewrite engine. If you look in Per-directory Rewrites on [apache docs](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html) you will see this. Alternatively `+SymLinksIfOwnerMatch` can be used, although I think all of this depends on your apache configuration, with respect to performance and security. – upful Nov 05 '13 at 18:43
  • 1
    `Options +FollowSymLinks` helped me. Thanks. – MartyIX Nov 14 '13 at 14:37
  • 3
    Worked like a charm... Would be grateful if you could also explain why. – Mołot Jan 12 '14 at 23:07
2

Check in the httpd.conf for the block of code. By default on a mac it's pretty restrictive. If it's only local and you don't care to much you can open it up like:

<Directory />
    Options All
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

That might help, or, could be the file permissions themselves. The /var/log/apache2/error_log and /var/log/apache2/access_log may also give you a bit more detail as to what's going on.

Tarun Gupta
  • 6,305
  • 2
  • 42
  • 39
2

The most likely cause is that your main conf file has the permissions restricted. Do you have a line like:

<Directory /> 
    AllowOverride None 
</Directory>

in your main conf file? This will stop you from being able to change basically anything using a .htaccess file.

You can find out more about apache permissions on their website.

Jeff Hutchins
  • 707
  • 7
  • 20
  • Yes, there was line "AllowOverride None", I've removed it, restarted apache, but it still gives me 403. Here's the current Directory section: Options FollowSymLinks (Here was AllowOverride None) Order deny,allow Deny from all – Dmitry Oct 05 '11 at 20:47
  • Instead of removing the AllowOverride line change it to ALL or an appropriate subset of the functionality you want. There's more info on those options at the [apache website](http://httpd.apache.org/docs/1.3/mod/core.html#allowoverride) – Jeff Hutchins Oct 05 '11 at 21:05
  • Also, you want to make sure that you don't have another Directory declaration that limits the Override permissions somewhere in your conf files and that the mod_rewrite extension is enabled. – Jeff Hutchins Oct 05 '11 at 21:11
0

Thanks to the Tarun's answer, Options All did the job for me :

<Directory "/path/to/apache/root"/>
    Options All
    ...
</Directory>