开发者

Rewrite logic breaking?

I have the following rewrite logic in my vHost and everything seems to be working in regards t开发者_StackOverflow社区o redirecting subdomains, but as soon as I add a path to the URI I'm getting an error in my apache_error.log.

Here is the rewrite logic:

    RewriteEngine On

    # Remove the www alias
    RewriteCond %{HTTP_HOST} ^www\.13labs\.net$ [NC]
    RewriteRule ^(.+)$ http://13labs.net$1 [R=301,L]

    RewriteCond %{REQUEST_URI} ^.+$
    RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf)$ [OR]
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_FILENAME} !-d [OR]
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^ - [L]

    RewriteCond %{HTTP_HOST} !^www\.13labs\.net$ [NC]
    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.13labs\.net$ [NC]
    RewriteRule ^(.+)$ /index.php?subdomain=%2&kohana_uri=$1 [PT,L,QSA]

    RewriteRule ^(.+)$ /index.php?kohana_uri=$1 [PT,L,QSA]

I am trying to hit admin.13labs.net/login, which should be rewriting to 13labs.net/index.php?subdomain=admin&kohana_uri=/login. However, in my apache_error.log I am receiving the following:

[Mon Aug 30 23:56:06 2010] [error] [client 74.63.151.37] File does not exist: /var/www/13labs.net/html/login

Any clues? I've been playing around with this for about an hour now and I'm stumped...

Regards, Andrew


Your second rewrite rule (with its corresponding conditions) looks like it'll stop rewrites for any URL. It matches if the file doesn't have the right extension, OR isn't a file, OR isn't a directory, OR isn't a link. No resource can be a file and a dir and a link at the same time, so all URLs will match -- and they'll all get passed as is, since your [L] flag prevents any subsequent rewrites.

If your intention is to prevent rewrites for URLs that correspond to existing files, links, or directories, remove the !'s from your conditions and remove the [OR] from the condition that checks the file extension.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜