普通问题 
收藏文章 楼主
各种环境伪静态规则合集(包括百度虚拟主机)
版块:用户提问   类型:精华   作者:乐天   查看:254   回复:1   获赞:0   时间:2018-12-07 19:32:37
apache(.htaccess):

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^list-([0-9]+)-([0-9]+)\.html$ index\.php\?c=list&sortid=$1&page=$2&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^list-high-([0-9]+)-([0-9]+)\.html$ index\.php\?c=list&type=high&sortid=$1&page=$2&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^user-([0-9]+).html$ index\.php\?c=user&id=$1&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^forum-([0-9]+).html$ index\.php\?c=forum&id=$1&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^user-([0-9]+)-([0-9]+).html$ index\.php\?c=user&id=$1&page=$2&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^center-([0-9]+).html$ index\.php\?c=center&uid=$1&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^center-([0-9]+)-([0-9]+).html$ index\.php\?c=center&uid=$1&page=$2&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^app-([0-9a-zA-Z_]+)-([0-9a-zA-Z_]+)\.html$ index\.php?c=app&a=$1:$2&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^read-([0-9]+)-([0-9]+)\.html$ index\.php\?c=read&id=$1&page=$2&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([a-zA-Z][0-9a-zA-Z_]+)\.html$ index\.php\?c=$1&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)\.hst$ - [F]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^logs/(.*)$ - [F]


nginx(.conf):

rewrite ^/list-([0-9]+)-([0-9]+)\.html$ /index.php?c=list&sortid=$1&page=$2 last;
rewrite ^/list-high-([0-9]+)-([0-9]+)\.html$ /index.php?c=list&type=high&sortid=$1&page=$2 last;
rewrite ^/user-([0-9]+)\.html$ /index.php?c=user&id=$1 last;
rewrite ^/user-([0-9]+)-([0-9]+)\.html$ /index.php?c=user&id=$1&page=$2 last;
rewrite ^/forum-([0-9]+)\.html$ /index.php?c=forum&id=$1 last;
rewrite ^/center-([0-9]+)\.html$ /index.php?c=center&uid=$1 last;
rewrite ^/center-([0-9]+)-([0-9]+)\.html$ /index.php?c=center&uid=$1&page=$2 last;
rewrite ^/read-([0-9]+)-([0-9]+)\.html$ /index.php?c=read&id=$1&page=$2 last;
rewrite ^/app-([0-9a-zA-Z_]+)-([0-9a-zA-Z_]+)\.html$ /index.php?c=app&a=$1:$2 last;
rewrite ^/downfile-([0-9]+)\.html$ /index.php?c=app&a=puyuetianeditor:index&s=showfile&id=$1 last;
rewrite ^/([a-zA-Z][0-9a-zA-Z_]+)\.html$ /index.php?c=$1 last;
location ~* /logs/.*$ {
	deny all;
}
location ~ \.hst$ {
	deny all;
}
参考地址:https://www.hadsky.com/read-3645-1.html



iis7(web.config):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
	<rewrite>
		<rules>
			<rule name="index">
				<match url="^index\.html$"  />
				<action type="Rewrite" url="index.php"  />
			</rule>
			<rule name="rule 1J">
				<match url="^list-([0-9]+)-([0-9]+)\.html$"  />
				<action type="Rewrite" url="index.php?c=list&amp;sortid={R:1}&amp;page={R:2}&amp;%1"  />
			</rule>
			<rule name="rule 2J">
				<match url="^list-high-([0-9]+)-([0-9]+)\.html$"  />
				<action type="Rewrite" url="index.php?c=list&amp;type=high&amp;sortid={R:1}&amp;page={R:2}&amp;%1"  />
			</rule>
			<rule name="rule 3J">
				<match url="^user-([0-9]+).html$"  />
				<action type="Rewrite" url="index.php?c=user&amp;id={R:1}&amp;%1"  />
			</rule>
			<rule name="rule 4J">
				<match url="^forum-([0-9]+).html$"  />
				<action type="Rewrite" url="index.php?c=forum&amp;id={R:1}&amp;%1"  />
			</rule>
			<rule name="rule 5J">
				<match url="^user-([0-9]+)-([0-9]+).html$"  />
				<action type="Rewrite" url="index.php?c=user&amp;id={R:1}&amp;page={R:2}&amp;%1"  />
			</rule>
			<rule name="rule 6J">
				<match url="^app-([0-9a-zA-Z_]+)-([0-9a-zA-Z_]+)\.html$"  />
				<action type="Rewrite" url="index.php?c=app&amp;a={R:1}:{R:2}&amp;%1"  />
			</rule>
			<rule name="rule 7J">
				<match url="^read-([0-9]+)-([0-9]+)\.html$"  />
				<action type="Rewrite" url="index.php?c=read&amp;id={R:1}&amp;page={R:2}&amp;%1"  />
			</rule>
			<rule name="rule 8J">
				<match url="^([0-9a-zA-Z_]+)\.html$"  />
				<action type="Rewrite" url="index.php?c={R:1}&amp;%1"  />
			</rule>
		</rules>
	</rewrite>
  </system.webServer>
</configuration>
参考地址:https://www.hadsky.com/read-3495-1.html



百度虚拟主机:

请先新建一个bcloud_nginx_user.conf文件,然后键入以下内容:

location / {
	rewrite ^/list-([0-9]+)-([0-9]+)\.html$ /index.php?c=list&sortid=$1&page=$2 last;
	rewrite ^/list-high-([0-9]+)-([0-9]+)\.html$ /index.php?c=list&type=high&sortid=$1&page=$2 last;
	rewrite ^/user-([0-9]+)\.html$ /index.php?c=user&id=$1 last;
	rewrite ^/user-([0-9]+)-([0-9]+)\.html$ /index.php?c=user&id=$1&page=$2 last;
	rewrite ^/forum-([0-9]+)\.html$ /index.php?c=forum&id=$1 last;
	rewrite ^/center-([0-9]+)\.html$ /index.php?c=center&uid=$1 last;
	rewrite ^/center-([0-9]+)-([0-9]+)\.html$ /index.php?c=center&uid=$1&page=$2 last;
	rewrite ^/read-([0-9]+)-([0-9]+)\.html$ /index.php?c=read&id=$1&page=$2 last;
	rewrite ^/app-([0-9a-zA-Z_]+)-([0-9a-zA-Z_]+)\.html$ /index.php?c=app&a=$1:$2 last;
	rewrite ^/downfile-([0-9]+)\.html$ /index.php?c=app&a=puyuetianeditor:index&s=showfile&id=$1 last;
	rewrite ^/([a-zA-Z][0-9a-zA-Z_]+)\.html$ /index.php?c=$1 last;
	location ~* /logs/.*$ {
		deny all;
	}
	location ~ \.hst$ {
		deny all;
	}
}

以utf8编码并保存后上传至ftp的webroot目录内,最后前往站点管理处 - 站点启停 - 重载站点配置即可。


更多规则欢迎大家扩展和补充!



陕西,西安

有些梦虽然遥不可及,但并不是不可能实现。 
回复列表
默认   热门   正序   倒序
花沁电子
2F
花心人Lv20
emotion
 0   9天前  回复

回复:各种环境伪静态规则合集(包括百度虚拟主机)

暂无用户组
退出
0级
游客:
网站建设

公告

近期本站被人为恶意注册及发布垃圾帖,本站已开启普通用户发帖审核功能,VIP系列用户组及开发者用户组不受影响,一但发现发布违法或垃圾帖的用户,该用户账号将会被永久封号,请大家共同维护互联网环境,共创美好互联网未来。

最新活动

3年个人版授权+2400天豆仅需154元

8年个人版授权+6400天豆仅需385元

终身个人版授权+5600天豆仅需539元

3年尊享版授权+24000天豆仅需1540元

8年尊享版授权+64000天豆仅需3850元

终身尊享版授权+56000天豆仅需5390元

HadSky 官方微信号
服务号 HadSky微信服务号 技术/文档/精帖
订阅号 HadSky微信订阅号 公告/更新/活动
关注送福利,登录送天豆

Powered by HadSky 6.5.6

©2015 - 2018 HadSky

购买产品 用户文档 加入QQ群 授权查询 网站绑定 客户案例 陕ICP备13005805号

您的IP:34.203.225.78,2018-12-17 03:18:02,Processed in 0.06823 second(s).

支持原创软件,抵制盗版,共创美好明天!
头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息
已有0次打赏