这是我的 web-root 的 htaccess 文件:
<IfModule mod_deflate.c>
# Force compression for mangled headers.
# http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/html
text/plain
text/x-component
text/xml
</IfModule>
</IfModule>
# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A24592000
ExpiresByType image/png A24592000
ExpiresByType image/jpg A24592000
ExpiresByType image/jpeg A24592000
ExpiresByType image/x-icon A24592000
ExpiresByType text/css A24592000
ExpiresByType text/javascript A24592000
RewriteEngine On
#do not rewrite for subdomains
RewriteCond %{HTTP_HOST} ^(www\.)?legendaily\.com$
#redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#only rewrite if it's not a file and not /login/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/login/
#rewrite /a/1 to /index.php?action=a&urlId=1
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?action=$1&urlId=$2 [L,QSA]
#rewrite /a to /index.php?action=a
RewriteRule ^([^/]+)/?$ index.php?action=$1 [L,QSA]
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
require valid-user
这是我在使用http://code.google.com/p/minify/的 /min 目录中使用的那个
<IfModule mod_rewrite.c>
RewriteEngine on
# You may need RewriteBase on some servers
#RewriteBase /min
# rewrite URLs like "/min/f=..." to "/min/?f=..."
RewriteRule ^([bfg]=.*) index.php?$1 [L,NE]
</IfModule>
<IfModule mod_env.c>
# In case AddOutputFilterByType has been added
SetEnv no-gzip
</IfModule>
现在我有两个问题:
- Google 无法访问根目录中的 Google-Site-Verification-File,因为它已被重写
- 我想使用子域来实现无 cookie,因此我已将 i.domain.com 和 s.domain.com 添加到我的服务器配置中,但如果我访问 s.domain.com/min,它会被重定向到网络-根。
谢谢你的帮助!