【问题标题】:How to get proper url rewriting with proper format in localhost?如何在 localhost 中以正确的格式重写正确的 url?
【发布时间】:2016-08-17 08:21:48
【问题描述】:

我的 .htaccess 文件如下,

DirectoryIndex routing.php

RewriteEngine on

RewriteBase  /

RewriteCond %{THE_REQUEST} \s/+Milan_Practice/Milan_Mvc/routing\.php[\s?] [NC]

RewriteRule ^ Milan_Practice/Milan_Mvc/ [L,R=302]

RewriteRule ^Milan_Mvc/?$ Milan_Mvc/routing.php [L,NC]

通过应用上面的代码,我得到了如下所示的网址,

http://localhost/Milan_Practice/Milan_Mvc/?name=about

在上面,“?”之后,数据不是我想要的有效格式,

http://localhost/Milan_Practice/Milan_Mvc/about/

所以请为上述代码提供适当的重写规则的建议

提前谢谢你!!!

【问题讨论】:

    标签: php localhost


    【解决方案1】:
    RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?name=$1 [QSA]
    

    http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

    【讨论】:

    • 我对重写 url 没有完全了解,所以给 RewriteRule 哪个,我可以直接应用到我的代码中
    • 这就是为什么我更愿意给你一个网址。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-20
    • 2017-05-21
    • 1970-01-01
    • 2011-07-09
    • 2011-03-17
    • 2017-07-13
    • 2011-07-27
    相关资源
    最近更新 更多