今天客户发了一段nginx的伪静态规则,让翻译,我们根据他的情况,进行了一下翻译。原来的nginx规则是这样的:
location / {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
改成apache的htaccess文件,是这样的:
RewriteEngine On
DirectoryIndex index.html index.htm index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?s=/$1 [L]
htaccess的伪静态规则与nginx的规则之间相互翻译,其实并不难,主要就是把每一条规则看明白。而且还有一点就是要注意调试,因为有些规则放到你服务器上是不行的,因为你不一定用的是apache,所以要看明白服务器的情况,适合用哪种规则。
还没有人来评论,快来抢个沙发吧!