开发者

mod_rewrite conflicts with Alias directive

开发者 https://www.devze.com 2023-02-23 01:23 出处:网络
My primary web site uses PHP/Zend Framework, and the .htaccess is the common one: RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR]

My primary web site uses PHP/Zend Framework, and the .htaccess is the common one:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Now I need to bring a forum (in another directory) to the main site. I added an Alias directive inside VirtualHost

Alias /forums "h:/projects/forums"

The forum software uses its own .htaccess. The main URL /fo开发者_如何转开发rums is accessible but not others. Other URLs (those who do not have corresponding files) are forwarded to the main site. In other words, the .htaccess file of the main site (/) is picked up, not the one under /forums directory.


Try adding a new RewriteCond to tell your main .htaccess file to ignore requests under /forums. After the request passes through that file, it should get picked up by the /forums/.htaccess file, though I'll admit that I'm not really sure if Alias affects this.

The condition would look like this:

RewriteCond %{REQUEST_URI} !^/forums [NC]

This says "only perform the next RewriteRule if the request doesn't begin with /forums". The [NC] at the end says to ignore the casing on /forums so it won't matter if the request is actually for /Forums or /FORUMS.

0

精彩评论

暂无评论...
验证码 换一张
取 消