.htaccess a specific folder is not rewriting
There is something strange going on. I am using Zend Framework on a subfolder in a site. I have a modular structure to my website, so the links consist of module names (www.xx.com/modulename). I have created a .htaccess file for the root dir, so that all of the requests would be routed to the public dir.
When i try to access the homepage ( www.xx.com) or any module it all goes exactly as it should. www.xx.com/authentication, www.xx.com/sample or www.xx.com/deathmetalreallyrox are all working as they should. But when I try to connect to www.xx.com/admin, it crashes and BURNS!!!! It does work however with www.xx.com/public/admin/.
Could it be, that my Hosting provider has set up some sort of rule in the httpd.conf to prevent me from accessing the admin section in my hosting? Here's my .htaccess:
SetEnv APPLICATION_ENV development
RewriteRule ^(browse|config).* - [L]
ErrorDocument 500 /error-docs/500.shtml
SetEnv CACHE_OFFSET 2678400
SetEnv APP_DOMAIN http://www.xx.com/public
SetEnv APP_PREF /public
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
开发者_如何学运维Header set Expires "Fri, 25 Sep 2037 19:30:32 GMT"
Header unset ETag
FileETag None
</FilesMatch>
RewriteEngine On
RewriteRule ^(adm|statistics) - [L]
RewriteRule ^admin/(.*) public/admin/$1
RewriteRule ^(.*)$ public/$1 [L]
Help?
EDIT: Browser error msg:
Not Found
The requested URL /admin/ was not found on this server.
You redirect anything starting with admin/
to public/admin/
first and then everything to public/whatever
. So when you request /admin/
, it's trying to give you /public/public/admin/
, which doesn't exist, so you get a 404.
Try removing the line RewriteRule ^admin/(.*) public/admin/$1
. It's already handled by the next line, and you don't want to do it twice.
It turned out, that the server was somehow configured wrongly.
As I do not have the total control over the server, I couldn't know, that there was a rule in the httpd.conf, that denied access to any folder named admin or administrator, so that when I tried to get the contents of a folder by this name, Apache first checked, if a folder by this name existed, and denied it by default.
So, the concise answer, the server was configured wrongly, didn't allow access to specific folders.
精彩评论