>  기사  >  백엔드 개발  >  htaccess规则。请高手帮写一下。多谢

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

WBOY
WBOY원래의
2016-06-13 13:47:51827검색

求一个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 on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
RewriteRule ^(.*)/([0-9]+)__tel/index.php $1/tel/index.php?id=$2 [QSA,L]

方法2.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteBase /tel/
RewriteRule ([0-9]+)__tel/index.php index.php?id=$1 [QSA,L] <div class="clear">
                 
              
              
        
            </div>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.