Forum Moderators: phranque

Message Too Old, No Replies

"RewriteEngine on" creates a "403 Forbidden" error

"mod_rewrite" missing? But it's within 'httpd.conf'

         

guarriman

5:57 pm on Feb 22, 2008 (gmt 0)

10+ Year Member



Hi.

I'm experiencing one problem with Apache2 on Linux. If
I insert a "RewriteEngine On" line in ".htaccess", webpages
return a "403 Forbidden Error".

I inserted these lines in 'httpd.conf':
------------
<Directory "/var/www/httpdocs">
Options Indexes FollowSymLinks
AllowOverride All
FCGIWrapper /var/www/httpdocs/bin/php5 .php5
FCGIWrapper /var/www/httpdocs/bin/php5 .php
Options ExecCGI
Allow from all
Order Allow,Deny
</Directory>
--------------

If I create a 'http://www.mydomain.com/phpinfo.php', there's no info about 'mod_rewrite'.

But if I open '/etc/httpd/conf/httpd.conf', I see:
-----
LoadModule rewrite_module modules/mod_rewrite.so
----

And if I list compiled modules:
--------------
[]# httpd -l
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c
--------------------

gergoe

7:01 pm on Feb 22, 2008 (gmt 0)

10+ Year Member



mod_rewrite is an Apache module, it has nothing to do with php, you should not find that in the output of phpinfo(). And you may not find in the compiled in modules neither, that depends on how you compiled your Apache (although I'm not sure you can build Apache with mod_rewrite built-in). if you are really interested about which modules are loaded into Apache (after the startup process), then consider enabling the mod_info module [httpd.apache.org].

Anyhow, if you have only the mentioned LoadModule, and no additional mod_rewrite directives, then turning on rewriting should not give you such a http status code, unless there are directives which makes mod_rewrite and Apache respond in such a manner (RewriteRule with the [F] flag for example).

Please note that placing an executable file (php5) into a directory which is visible to the world, is not a good idea, it is recommended to avoid this due to security issues.

Unless someone else have a better idea (or the directives below didn't solve your problem), post the relevant part of your httpd.conf or .htaccess file, perhaps you are just looking to the wrong place.

By the way, your directory definition can be simplified (and improved) to:

<Directory /var/www/httpdocs> 
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
FCGIWrapper /var/www/httpdocs/bin/php5 .php5
FCGIWrapper /var/www/httpdocs/bin/php5 .php
# Maybe this line will solve your problem anyway
Allow from all
Order Allow,Deny
</Directory>

guarriman

7:46 pm on Feb 22, 2008 (gmt 0)

10+ Year Member



Yes, you're right.

I had an extra Options line (with ExecCGI) which overwrote the previous one (with FollowSymLinks).

It works now! Thank you very much!