httpd.ini的[ISAPI_Rewrite]
CacheClockRate 3600
RepeatLimit 32
RewriteRule /(\d+)\.html /index\.php\?p=$1
RewriteRule /(\d+) /s\.php\?id=$1
RewriteRule /(\d+)/index\.html /s\.php\?id=$1
http://www.jvvhb.info/123/3.html
URL重写
http://www.jvvhb.info/s.php?k=123&x=3前面的目录重写已经成功了,大家可以参考下
CacheClockRate 3600
RepeatLimit 32
RewriteRule /(\d+)\.html /index\.php\?p=$1
RewriteRule /(\d+) /s\.php\?id=$1
RewriteRule /(\d+)/index\.html /s\.php\?id=$1
http://www.jvvhb.info/123/3.html
URL重写
http://www.jvvhb.info/s.php?k=123&x=3前面的目录重写已经成功了,大家可以参考下
解决方案 »
- 企业内部建BBS系统可以用什么免费论坛程序?
- mysql_query执行失败,但是直接把sql语句放到phpmyadmin里面却可以执行为什么?
- 有人使用过drupal吗?请进来看看
- 安装mantis
- 想要运行一个文件共享平台用什么现成的框架比较好?
- 求php 的floyd 算法!
- 55.la程序是什么原理
- codeigniter整合ucenter,老是通信失败
- phpStudy (php环境集成包) +JspStudy (JSP环境集成包) 求测试
- php 操作mongodb 关于操作符 $slice $elemmatch的用法
- foreach循环一维数组的问题
- 最普通的form undefined index error.
照葫化瓢呗~
english
русский简体中文
עברית
日本語
türkçe新闻 [en]
nginx 介绍
下载 [en]
安全漏洞 [en]
文档
FAQ
外部连接 [en]
书籍 [en]
支持 [en]
捐献 [en]trac
wiki
twitter
nginx.com
This translation may be out of date. Check the English version for recent changes.
转化混合规则
重定向到主站
共享站点的管理员,习惯于只在Apache下使用.htaccess文件配置所有信息,通常会将下面规则 RewriteCond %{HTTP_HOST} nginx.org
RewriteRule (.*) http://www.nginx.org$1
翻译成这样: server {
listen 80;
server_name www.nginx.org nginx.org;
if ($http_host = nginx.org) {
rewrite (.*) http://www.nginx.org$1;
}
...
}这种做法是错的,复杂而且低效。正确的方式是为nginx.org定义一个单独的服务器: server {
listen 80;
server_name nginx.org;
return 301 http://www.nginx.org$request_uri;
}server {
listen 80;
server_name www.nginx.org;
...
}在0.9.1版本(含)以前,可以这样实现重定向:
rewrite ^ http://www.nginx.org$request_uri?;再举一个例子,处理一个和刚才相反的逻辑:既不是来自nginx.com,又不是来自www.nginx.com: RewriteCond %{HTTP_HOST} !nginx.com
RewriteCond %{HTTP_HOST} !www.nginx.com
RewriteRule (.*) http://www.nginx.com$1
应该按下面这样分开定义nginx.com、www.nginx.com和其他站点: server {
listen 80;
server_name nginx.com www.nginx.com;
...
}server {
listen 80 default_server;
server_name _;
return 301 http://nginx.com$request_uri;
}在0.9.1版本(含)以前,可以这样实现重定向:
rewrite ^ http://nginx.com$request_uri?;转化混合规则
典型的混合规则如下: DocumentRoot /var/www/myapp.com/current/publicRewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ %{DOCUMENT_ROOT}/system/maintenance.html [L]RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1 [QSA,L]RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule ^(.*)$ $1/index.html [QSA,L]RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1/index.html [QSA,L]RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
转换成nginx配置应该是这样: location / {
root /var/www/myapp.com/current/public; try_files /system/maintenance.html
$uri $uri/index.html $uri.html
@mongrel;
}location @mongrel {
proxy_pass http://mongrel;
}