ホームページ  >  記事  >  バックエンド開発  >  htaccess规则。请高手帮写一下。多谢

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

WBOY
WBOYオリジナル
2016-06-13 10:09:16805ブラウズ

求一个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]<div class="clear">
                 
              
              
        
            </div>
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。