我在Apache 2.2下面临虚拟主机的一些问题。
我想在我的本地环境中托管一些网站的开发版本(其中一些使用codeigniter),并且能够使用“.dev”扩展名访问它们,所以我可以去:
- http://myproject.dev to access the local version or
- http://myproject.com to access production version
我已经设置了一些基于名称的虚拟主机,如下所示:
NameVirtualHost localhost
<VirtualHost localhost>
DocumentRoot ".../workspace.web/"
ServerName localhost
</VirtualHost>
NameVirtualHost myproject.dev
<VirtualHost myproject.dev>
DocumentRoot ".../workspace.web/myproject.com/htdocs"
ServerName myproject.dev
</VirtualHost>
并设置我的主机文件
127.0.0.1 psychologuenice.dev
主页工作正常,但子目录在codeigniter中崩溃。例如
myproject.dev/whatever
返回404错误。
我不确定htaccess中的任何规则是否可能导致这种情况,或者仅仅是由于对我在这里所做的事情的理解不足。我的htaccess看起来像这样:
#RewriteEngine on
#RewriteCond $1 !^(index\.php|robots\.txt|images|css|js|captcha|inc|html|tmp|captcha)
#RewriteRule ^(.*)$ /index.php/$1 [QSA,L]
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [QSA,L]
</IfModule>
# BEGIN Compress text files
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>
# END Compress text files
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers
# BEGIN Turn ETags Off
FileETag None
# END Turn ETags Off
有人能给出任何线索吗?