锦尚中国源码论坛提供的搜索程序2.0版伪静态全新调整了,更简单的规则,后台随时自定义伪静态规则,不用再手动修改文件。目录格式还是.html后缀模式有你决定!
附程序下载地址:http://bbs.52jscn.com/thread-3300622-1-1.html
例如:
/k/关键词 后台应设置 k/{q} 和 k/{q}/{p}
/关键词.html 后台应设置 {q}.html 和 {q}_{p}.html
/s/关键词.html 后台应设置 s/{q}.html 和 s/{q}_{p}.html
还可以吧“关键词”base64转码,例如:
/5YWz6ZSu6KN.html 后台应设置 {qe}.html 和 {qe}_{p}.html
在后台设置伪静态规则的时候,建议使用“/”或者“_”这两个字符来分割,不要用其它特殊字符,以免冲突出错
2.X的程序里已经包含了伪静态规则
以下是2.X版的伪静态规则:
Nginx版:
if (!-e $request_filename) {rewrite /(.*) /index.php?rewrite=$1 last;}
Nginx版(放“so”子目录):
if (!-e $request_filename) {rewrite /so/(.*) /so/index.php?rewrite=$1 last;}
请注意:如果设置伪静态后搜索中文乱码,请在规则RewriteRule ^(.*)$ /index.php?rewrite=$1后面加上 [QSA,NU,PT,L]
Apache版(.htaccess文件)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?rewrite=$1
</IfModule>
Apache版(放“so”子目录)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /so/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=$1
</IfModule>
IIS版,IIS6.0下的httpd.ini伪静态就没有那么灵活了
[ISAPI_Rewrite]
CacheClockRate 3600
RepeatLimit 32
RewriteRule ^/sitemap/$ /index\.php\?rewrite=sitemap/
RewriteRule ^/sitemap/(.*).html$ /index\.php\?rewrite=sitemap/$1.html
RewriteRule ^/k/(.*)/(.*)$ /\?q=$1&p=$2
RewriteRule ^/k/(.*)$ /\?q=$1
IIS版(放“so”子目录)
[ISAPI_Rewrite]
CacheClockRate 3600
RepeatLimit 32
RewriteRule ^/so/sitemap/$ /so/index\.php\?rewrite=sitemap/
RewriteRule ^/so/sitemap/(.*).html$ /so/index\.php\?rewrite=sitemap/$1.html
RewriteRule ^/so/k/(.*)/(.*)$ /so/\?q=$1&p=$2
RewriteRule ^/so/k/(.*)$ /so/\?q=$1
IIS7/IIS7.5 web.config规则
<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><security><requestFiltering allowDoubleEscaping="true"></requestFiltering></security><rewrite><rules><rule name="OrgPage" stopProcessing="true"><match url="^(.*)$"/><conditions logicalGrouping="MatchAll"><add input="{HTTP_HOST}" pattern="^(.*)$"/><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/></conditions><action type="Rewrite" url="index.php?rewrite={R:1}"/></rule></rules></rewrite></system.webServer></configuration>