首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

htaccess规则。请高手帮写一下。多谢

2012-03-11 
求一个htaccess规则。请高手帮写一下。谢谢求一个htaccess规则/tel/index.php?id4转换成下面这样/4__tel/in

求一个htaccess规则。请高手帮写一下。谢谢
求一个htaccess规则

/tel/index.php?id=4 转换成下面这样

/4__tel/index.php

[解决办法]
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^.*/([0-9]+)__tel/index.php /tel/index.php?id=$1 [QSA,L]
[解决办法]
([0-9]+) ,[]表示一个范围 0-9的任意一个数字!
[解决办法]
apache 配置文件中的 rewrite_module 开了吗?
[解决办法]

PHP code
方法1.    RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,L]RewriteRule ^(.*)/([0-9]+)__tel/index.php $1/tel/index.php?id=$2 [QSA,L]方法2.RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteBase /tel/RewriteRule ([0-9]+)__tel/index.php index.php?id=$1 [QSA,L] 

热点排行