我如何在友好的URL使用GET方法。友好、方法、如何在、URL

2023-09-02 09:46:07 作者:神仙哥哥.

我的网址是: http://rang.comli.com/servicecnt/service_id/5 。 使用.htaccess文件,我已经建立了友好url.I要使用$ _GET method.So到目前为止,我在PHP这样做来获取URL值,但我想知道如何使用$ _ GET方法获取和分配变量。

 < PHP
    $ HTP = $ _ SERVER ['REQUEST_URI'];
    $ htp_arr =爆炸(/,$ HTP);
    回声$ HTP;
    回声< pre>中;
    的print_r($ htp_arr)< BR />中。
    回声ID =$ htp_arr [3]&所述峰; br />中。;
    回声NAME =$ htp_arr [2]< BR />中。;
    回声名称2 =$ htp_arr [1]。&所述峰; br />中;
?>
 

解决方案

如果你使用的.htaccess的然后只需使用:

  $服务ID = $ _GET ['service_id为'];
 
如何在本地电脑中用到图片的URL地址

有关形式予以URI添加此规则:

 重写规则^形式予以/ tution_id /( d +)/ $ tution.php?tution_id == $ 1 [QSA,L]
 

my url is:http://rang.comli.com/servicecnt/service_id/5. Using .htaccess file,I have created the friendly url.I want to retrieve the url values by using $_GET method.So far I have done in php like this,but I want to know how to get by using $_GET method and assign to variable.

<?php
    $htp=$_SERVER['REQUEST_URI'];
    $htp_arr=explode("/",$htp);
    echo $htp;
    echo "<pre>";
    print_r($htp_arr)."<br/>";
    echo "ID=".$htp_arr[3]."<br/>";
    echo "Name=".$htp_arr[2]."<br/>";
    echo "Name2=".$htp_arr[1]."<br/>";
?>

解决方案

If you're using .htaccess from this answer then just use:

$serviceId = $_GET['service_id'];

For tution URI add this rule:

RewriteRule ^tution/tution_id/(d+)/?$ tution.php?tution_id==$1 [QSA,L]