如何在localhost中以适当的格式重写正确的url?

时间:2016-08-17 08:21:49

标签: php localhost

我的.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]

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

http://localhost/Milan_Practice/Milan_Mvc/?name=about
上面的

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

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

因此,请为上述代码提供适当的重写规则

谢谢你提前!!!

1 个答案:

答案 0 :(得分:0)

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