伪静态规则怎么写 (伪静态php - htaccess伪静态)

文章编号:3847 更新时间:2024-01-19 分类:互联网资讯 阅读次数:

资讯内容

本文目录:

如何应用.htaccess文件对PHP网站或文件启动伪静态处置

应用.htaccess文件对PHP网站启动伪静态处置要思考两点:

伪静态规则怎么写伪静态phphtacce

一.主机支持伪静态,比如Apache要开启mod_rewrite模块支持

二.应用.htaccess成功伪静态须要依据不同的网站系统启动不同的设置,以下是一些经常出现系统的.htaccess设定:

01.wordpress:

BEGINWordPress

IfModulemod_rewrite.c

RewriteEngineOn

RewriteBase/

RewriteRule^index.php$–[L]

RewriteCond%{REQUEST_FILENAME}!-f

RewriteCond%{REQUEST_FILENAME}!-d

RewriteRule./index.php[L]

02.Phpwind

RewriteEngineOn

RewriteBase/

RewriteRule^(.*)-htm-(.*)$$1.php?$2

RewriteRule^(.*)simple/([a-z0-9\_]+\.html)$$1/simple/index.php?$2

RewriteEngineOn

Rewrite系统规定请勿修正

RewriteRule^archiver/((fid|tid)-[0-9]+\.html)$archiver/index.php?$1

RewriteRule^forum-([0-9]+)-([0-9]+)\.html$forumdisplay.php?fid=$1page=$2

RewriteRule^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$viewthread.php?tid=$1extra=page\%3D$3page=$2

RewriteRule^space-(username|uid)-(.+)\.html$space.php?$1=$2

RewriteRule^tag-(.+)\.html$tag.php?name=$1

RewriteEngineOn

directone-wordaccess

RewriteRule^index\.html$index\.php[L]

RewriteRule^category$index\.php[L]

accessanyobjectbyitsnumericidentifier

RewriteRule^feed-c([0-9]+)\.xml$feed\.php\?cat=$1[L]

RewriteRule^feed-b([0-9]+)\.xml$feed\.php\?brand=$1[L]

RewriteRule^feed\.xml$feed\.php[L]

RewriteRule^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$category\.php\?id=$1brand=$2price_min=$3price_max=$4filter_attr=$5page=$6sort=$7order=$8[QSA,L]

RewriteRule^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$category\.php\?id=$1brand=$2price_min=$3price_max=$4filter_attr=$5[QSA,L]

RewriteRule^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$category\.php\?id=$1brand=$2page=$3sort=$4order=$5[QSA,L]

RewriteRule^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$category\.php\?id=$1brand=$2page=$3[QSA,L]

RewriteRule^category-([0-9]+)-b([0-9]+)(.*)\.html$category\.php\?id=$1brand=$2[QSA,L]

RewriteRule^category-([0-9]+)(.*)\.html$category\.php\?id=$1[QSA,L]

RewriteRule^goods-([0-9]+)(.*)\.html$goods\.php\?id=$1[QSA,L]

RewriteRule^article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$article_cat\.php\?id=$1page=$2sort=$3order=$4[QSA,L]

RewriteRule^article_cat-([0-9]+)-([0-9]+)(.*)\.html$article_cat\.php\?id=$1page=$2[QSA,L]

RewriteRule^article_cat-([0-9]+)(.*)\.html$article_cat\.php\?id=$1[QSA,L]

RewriteRule^article-([0-9]+)(.*)\.html$article\.php\?id=$1[QSA,L]

RewriteRule^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.htmlbrand\.php\?id=$1cat=$2page=$3sort=$4order=$5[QSA,L]

RewriteRule^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.htmlbrand\.php\?id=$1cat=$2page=$3[QSA,L]

RewriteRule^brand-([0-9]+)-c([0-9]+)(.*)\.htmlbrand\.php\?id=$1cat=$2[QSA,L]

RewriteRule^brand-([0-9]+)(.*)\.htmlbrand\.php\?id=$1[QSA,L]

RewriteRule^tag-(.*)\.htmlsearch\.php\?keywords=$1[QSA,L]

RewriteRule^snatch-([0-9]+)\.html$snatch\.php\?id=$1[QSA,L]

RewriteRule^group_buy-([0-9]+)\.html$group_buy\.php\?act=viewid=$1[QSA,L]

RewriteRule^auction-([0-9]+)\.html$auction\.php\?act=viewid=$1[QSA,L]

RewriteEngineOn

RewriteRule^(.*)content-([0-9]+)-([0-9]+)-([0-9]+)\.html$$1/index\.php\?m=contentc=indexa=showcatid=$2id=

RewriteRule^(.*)show-([0-9]+)-([0-9]+)-([0-9]+).html$$1/index\.php\?m=contentc=indexa=showcatid=$2id=

RewriteRule^(.*)list-([0-9]+)-([0-9]+).html$$1/index\.php\?m=contentc=indexa=listscatid=$2page=$3

ASP伪静态可以支持.htaccess吗?

可以,用kangle反代asp插件

IIS平台并不支持.htaccess,IIS只支持httpd.ini,Apache主机才支持.htaccess;

假设你的ASP不是运转在Apache平台上,你可以将.htaccess规定转换成httpd.ini规定。

如何设置伪静态规定

设置伪静态规定的详细步骤如下:

以IIS10下设置伪静态规定为例:

1、首先须要装置Url重写模块,百度搜查,下载完装置,URLRewriteModule。

2、而后重启机器,可以在iis全局看到URLrewrite模块。

3、而后点击要设置伪静态规定的站点,双击URL重写图标。

4、而后进入URL重写界面,点击右侧的导入规定。

5、进入导入mod_rewrite界面,点击性能文件上方框最后的三个点。

6、找到伪静态规定文件:.htaccess,选中并点击关上。

7、回到导入mod_rewrite界面,点击导入规定。

8、最后,点击右栏的运行按钮。

9、至此伪静态性能成功,iis上的伪静态规定是写在web.confg,在网站根目录上web.confg已写上关系程序规定

apache伪静态如何暗藏index.php?

Apache伪静态性能方法有两种:

在网站根目录下减少文件,.htaccess,在此文件内写伪静态规定,经常使用它须要在apache性能文件http.conf中成功相应性能.详细性能方法网上很多,这里不再赘述.

而另一种是间接在httpd.conf中经常使用.这种方法性能高于前者。

运行场景

(1),驳回.htaccess的场景

用户须要针对特定目录扭转主机的性能而又没有root权限的状况下,可以经过.htaccess文件成功。

假设主机治理员不情愿频繁修正性能,则可以准许用户经过.htaccess文件自己修正性能.比如ISP,在同一个机器上运转了多个用户站点,宿愿用户可以自

己扭转性能,便可以性能好apache,开启对.htaccess文件的支持即可.

(2),不驳回.htaccess的场景

只管上述步骤1可以成功,但普通都应该尽或许地防止经常使用.htaccess文件。任何宿愿放在.htaccess文件中的性能,都可以放在主性能文件(http.conf)的段中,而且更高效。

(3)防止经常使用.htaccess文件有两个重要要素

首先是性能。假设AllowOverride启用了.htaccess文件,则Apache须要在每个目录中查找.htaccess文件,因此,无论能否真正用到,启用.htaccess都会造成

性能的降低。另外,对每一个恳求,都须要读取一次性.htaccess文件。

还有,Apache必定在一切下级的目录中查找.htaccess文件,以使一切有效的指令都起作用,所以,假设恳求/www/htdocs/example中的页面,Apache必定查找以下文件:

/.htaccess

/www/.htaccess

/www/htdocs/.htaccess

/www/htdocs/example/.htaccess

总共要访问4个额外的文件,即使这些文件都不存在。(留意,这或许仅仅由于准许根目录/经常使用.htaccess,只管这种状况并不多。)

其次是安保。这样会准许用户自己修正主机的性能,这或许会造成某些意想不到的修正,所以请仔细思考能否应当给予用户这样的特权。然而,假设给予用

户较少的特权而不能满足其须要,则会带来额外的技术支持恳求,所以,必定明白地通知用户曾经给予他们的权限,说明AllowOverride设置的值,并疏导他

们参阅相应的说明,免得日后生出许多费事。

留意,在/www/htdocs/example目录下的.htaccess文件中搁置指令,与在主性能文件中段中搁置相反指令,是齐全等效的。

总结

由上咱们可以知道,经常使用.htaccess文件具备性能上的不利之处,所以咱们应该尽或许防止经常使用.htaccess文件,上方引见一种不经常使用.htaccess文件启动伪静态

的方法:

Apache1.x的用户请审核conf/httpd.conf中能否存在如下两段代码:

LoadModulerewrite_modulelibexec/mod_rewrite.so

AddModulemod_rewrite.c

Apache2.x的用户请审核conf/httpd.conf中能否存在如下一段代码:

LoadModulerewrite_modulemodules/mod_rewrite.so

假设存在,且以扫尾,请删除。而后在性能文件(理论就是conf/httpd.conf或许conf/extra/httpd-vhosts.conf)中参与如下代码。此时请务必留意,假设网

站经常使用经过虚构主机来定义,请务必加到虚构主机性能段中去,假设加在虚构主机性能外部将或许不可经常使用。改好后而后将Apache重启。

①.在apache性能文件httpd.conf中找到:

LoadModulerewrite_modulemodules/mod_rewrite.so

这句,去掉前边的注释符号,假设没有则减少这句。

②.在代码:

OptionsFollowSymLinks

AllowOverrideNone

上方减少伪静态代码(以Wordpress伪静态为例):

RewriteEngineOn

RewriteBase/

RewriteRule^index.php$–[L]

RewriteCond%{REQUEST_FILENAME}!-f

RewriteCond%{REQUEST_FILENAME}!-d

RewriteRule./index.php[L]

其中/usr/local/apache/htdocs/wwwtest即为要启动伪静态的网站的根目录

③.重启apache

kangle支持.htaccess伪静态吗

kangle是支持htaccess伪静态的。

htaccess伪静态规定

IfModulemod_rewrite.c

RewriteEngineon

RewriteCond%{REQUEST_FILENAME}!-f

RewriteCond$1!^(index\.php|samples|robots\.txt|views|plugins|backup|upload|images|install|admin123|plug|test|install|make|js|favicon\.ico|templates|mqqt|scl|app)

RewriteRule^(.*)$index.php/$1[L]

Centos下让nginx支持.htaccess文件成功伪静态的方法

Centos下让nginx支持.htaccess文件成功伪静态的方法在Google上搜查的资料很多人都说nginx目前不支持.htaccess文件,我依照nginx的规定实验了一下,结果发现

nginx是齐全支持.htaccess文件的!方法如下:1.

在须要经常使用.htaccess文件的目录下新建一个.htaccess文件,如我的一个Discuz论坛目录:vi

/var/www/html/bbs/.htaccess

在外面输入规定,我这里输入Discuz的伪静态规定:

rulerewrite

^(.*)/archiver/((fid|tid)-[w-]+.html)$

$1/archiver/index.php?$2

last;rewrite

^(.*)/forum-([0-9]+)-([0-9]+).html$

$1/forumdisplay.php?fid=$2page=$3

last;rewrite

^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$

$1/viewthread.php?tid=$2extra=page%3D$4page=$3

last;rewrite

^(.*)/profile-(username|uid)-(.+).html$

$1/viewpro.php?$2=$3

last;rewrite

^(.*)/space-(username|uid)-(.+).html$

$1/space.php?$2=$3

last;rewrite

^(.*)/tag-(.+).html$

$1/tag.php?name=$2

rulewq保留分开。3.

修正nginx性能文件:

/etc/nginx/nginx.conf4.

在须要减少伪静态的虚构主机的server{}中引入.htaccess文件,include

/var/www/html/bbs/.htaccessinclude

/var/www/html/bbs/.htaccess;(把这个改成你.htaccess文件的详细位置)wq保留分开。5.

从新加载nginx性能文件:/etc/init.d/nginx

reload从新关上网页看看,假设伪静态反常就证实你的rewrite

rule语法是正确的。

介绍阅读:

标签: htaccess伪静态

本文地址: https://yihaiquanyi.com/article/e78fa503e21deeb77036.html

上一篇:teamviewer手机版TeamViewer教程如何将创建...
下一篇:华纳云北京科技有限公司华纳云双11钜惠出海...

发表评论