Forum Moderators: phranque

Message Too Old, No Replies

AllowOverride not allowed here

Problems with .htaccess files in Apache2

         

gcan

5:07 pm on Mar 20, 2008 (gmt 0)

10+ Year Member



Hello,

Can anyone help to solve problem with overriding in Apache2 ?

I have enabled mod_rewrite in Apache2.
AllowOverride is set to All in virtual host configuration.

But Apache just ignores my .htaccess file with rewrite rules. When I add this line to my .htaccess file:

AllowOverride All

I get Internal Server Error and error.log file says:

AllowOverride not allowed here

This is my virtual host configuration:


<VirtualHost *:80>
ServerName www.modomain.eu
ServerAlias mydomain.eu *.mydomain.eu mydomain.es *.mydomain.es
DocumentRoot /home/sites/mydomain.es
<Directory /home/sites/mydomain.es>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
AllowOverride All
</Directory>
</VirtualHost>

This is my .htaccess file:

------------------
Options +FollowSymLinks

RewriteEngine on

RewriteRule ^/uid/([0-9]+)$ /profile.php?uid=$1 [PT]
------------------

Thanks.

jdMorgan

7:17 pm on Mar 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As documented, AllowOverride is not allowed in .htaccess files. BUt it does not appear to be needed in your case anyway.

The problem is that URL-paths "seen" by RewriteRule in a .htaccess context do not include the path to the current directory -- This is why they're called "per-directory" config files.

Removing the leading slash from the pattern in your RewriteRule will probably fix your immediate problem.

Also, be aware that it is the client (e.g. browser) which resolves relative links. If you use page-relative links on your profile.php pages, then you will either have to change them to server-relative or canonical links, or you will have to rewrite those links as well, to remove the "/uid" prefix.

Jim

gcan

8:19 pm on Mar 20, 2008 (gmt 0)

10+ Year Member



jdMorgan, thank you for reply.
I don't use AllowOverride in my htaccess file. I was just making some tests.

I tried to remove leading slash from RewriteRule, but it doesn't help. When I try to access address like: [mydomain...] I get empty page with 404 Not Found error.

I was using .htaccess files in previous versions of Apache, but never had problems like this. :(