【发布时间】:2010-01-10 20:44:08
【问题描述】:
这是我的 htaccess 文件
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/chat/
RewriteCond %{REQUEST_URI} !^/m/
RewriteCond %{REQUEST_URI} !^/__admin/
RewriteCond %{REQUEST_URI} !^/gzip_headers.php
RewriteCond %{REQUEST_URI} !^/phpfreechat/
RewriteCond %{REQUEST_URI} !^/_temp/
RewriteRule ^.+\.php$ index.php [L]
RewriteRule ^.*\.css gzip_headers.php [L]
RewriteRule ^.*\.js gzip_headers.php [L]
RewriteRule ^classifieds/ /index.php [L]
RewriteCond %{REQUEST_URI} !^/movies/.
RewriteRule ^movies/ /index.php [L]
RewriteCond %{REQUEST_URI} !^/games/.
RewriteRule ^games/ /index.php [L]
RewriteRule ^jntu/ /index.php [L]
RewriteRule ^news/ /index.php [L]
我的想法基本上是,
- 将所有内容转发到 public_html/index.php(某些目录除外)
- 将所有 js 和 css 转发到 gzip 文件,(我这样做主要是因为我不只是 gzip 压缩它们,而是在 tha phpfile 中压缩)
- 问题是当我从子目录加载图像时,它们也被重定向到 index.php,因此只需为这些目录创建条件并将图像存储在其中,如
RewriteCond %{REQUEST_URI} !^/games/.
我想让这样的事情变得简单
- 将所有内容转发到 index.php(顶部的某些条件除外)
- 将 css 和 js 转发到 gzip 文件
- 仅当它们存在时才立即加载图像和闪存以及其他一些 MIME 类型。 (jpg|gif|png|swf|flv|mp4|3gp|mp3|zip|rar|exe)
我猜类似于逻辑 AND REQUEST_URI 和 -f 标志
【问题讨论】:
标签: .htaccess mod-rewrite redirect