duanjiaoxi4928 2016-03-08 06:56
浏览 9

如何更改php中的url变量?

How do i change the url http://localhost/Test/www/#/home/login.php?name=abc
to http://localhost/Test/www/#/home/login/abc

I need to access the name variable from url

I have tried to modify .htaccess but i am getting. Please some help me out.

  • 写回答

1条回答 默认 最新

  • dtid30526 2016-03-08 07:13
    关注

    For you to achieve that, you can do a mod_rewrite (placed in an .htaccess file) rule that looks something like this:

    RewriteEngine on
    RewriteRule ^/login/([0-9]+)\.html /login.php?name=abc
    

    And this maps requests from

    /login.php?name=abc
    

    to

    /login/abc.html
    

    Another possibility is doing it with forcetype, which forces anything down a particular path to use php to eval the content. So, in your .htaccess file, put the following:

    <Files login>
        ForceType application/x-httpd-php
    </Files>
    

    And then the index.php can take action based on the $_SERVER['PATH_INFO'] variable:

    <?php
        echo $_SERVER['PATH_INFO'];
        // outputs '/abc.html'
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类