开发者

.htaccess to vhost

Anyone know what to put in vhost.conf for apache to replicate this (from .htaccess):

RewriteEngine on  
RewriteCond $1 !^(index\.php|images|scripts|css|uploads|robots\.txt)  
RewriteRule ^(.*)$ /index.php/$1 [L]  

Basically I want all requests except those for /images, /scripts or /css to go through /index.php.

It works when I use the .htaccess file but I'd like to know how to do it via vhost.conf as well. Anyone know if it's better to use one over the other as well (vhost.conf vs htaccess) in te开发者_StackOverflow中文版rms of performance, stability, etc?


It should work when prepending the pattern with /, either:

RewriteCond $1 !^(index\.php|images|scripts|css|uploads|robots\.txt)
RewriteRule ^/(.*)$ /index.php/$1 [L]

Or:

RewriteCond $1 !^/(index\.php|images|scripts|css|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

The disadvantage of .htaccess files is simply that they virtually need to be interpreted with every request while the virtual host configuration is just interpreted once when the server is started.


Gumbo++

I wrote this article on the httpd wiki to cover questions like this one.

http://wiki.apache.org/httpd/RewriteContext

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜