Jump to content

.htaccess bypassed for virtual host *solved*


Psycoder

Recommended Posts

Earlier this week I tried a few things out on my website (which is still in development, and still local). I used an .htaccess to redirect all incoming requests (that were not images and the like) through a certain file (which eventually included the site from out of the public folder). When I started my computer up the day after, the local website gave an 403 forbidden error. This was because he suddenly did no longer see my file (I used to redirect all incoming requests to another file in .htaccess). After a few tests, I found out my website did not use any of the commands in the .htaccess file. I am guessing something in the apache configuration file must be able to trigger .htaccess again, however I can't remember changing that file lately.
This website is set up as a virtual host, so here is the code of the virtual host:

[code]<VirtualHost *:80>
    ServerName www.example.com
    ServerAdmin admin@localhost
    DocumentRoot path/to/website/public
    AllowOverride All
</VirtualHost>[/code]

.htaccess:
[code]
Order deny,allow
Deny from all
Allow from localhost
Options -Indexes

RewriteEngine on
RewriteRule !\.(gif|jpg|png|css|js)$ parserfile.bla
[/code]

parserfile.bla includes a different file from outside the public folder (ie ../secretfolder/index.php)

Beyond renaming some paths and such, this is the information from those files.

Now I mainly wonder what exactly can keep apache from using that .htaccess? Something must have changed to restrict use for it.

My second question is more of an optimisation question. Is there a way to let .htaccess redirect everything to another file outside the public folder? "RewriteRule !\.(gif|jpg|png|css|js)$ ../secretfolder/index.php" seems not to work.

But the main question remains, what can keep apache from using .htaccess files?
Link to comment
Share on other sites

This weekend, now I had time to work on this again, I finally found out what stupid mistake I had made.

in the .htaccess file was written:
[code]Order deny,allow
Deny from all
Allow from localhost[/code]
This used to work on my first set up of this website long ago, however I changed a few things since then. I no longer use it under localhost (One project had split up in two, as to effectively devide the problem in smaller portions). Now that it has moved, and I myself do not use localhost anymore, I had to change it to
[code]Allow from 127.0.0.1[/code]

It's always the small things that are overlooked :P
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.