我已经创建了网站,我想更改其网址结构。例如, 。我无法更改我的PHP网站中的URL结构
http://www.haitibravo.com/market/detail.php?add_id=73
我想不显示它?标记像
http://www.haitibravo.com/market/product/73
我如何显示这样的网址。请帮帮我。我尝试了很多技巧,但我失败了。
我已经创建了网站,我想更改其网址结构。例如, 。我无法更改我的PHP网站中的URL结构
http://www.haitibravo.com/market/detail.php?add_id=73
我想不显示它?标记像
http://www.haitibravo.com/market/product/73
我如何显示这样的网址。请帮帮我。我尝试了很多技巧,但我失败了。
制作一个.htaccess文件并在其中保存下面的代码。
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?r=$1
RewriteRule ^([a-zA-Z0-9_-]+)/item/$ index.php?r=$1
我应该将这些行添加到.htaccess文件? –
是的。还有一件事,如果你在localserver上运行它。然后搜索谷歌如何运行.htaccess您使用的本地主机上的软件。 – Abdullah
否否我在我的网站上运行它 –
RewriteEngine On
/* this enables you to write urls in desired fashion */
RewriteRule ^([a-zA-Z0-9_-]+)$ detail.php?add_id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/product/$ detail.php?add_id=$1
/*Something like this should redirecto from detail.php?add_id=n to your desired url */
RewriteCond %{THE_REQUEST} /(?:detail\.php)?\?add_id=([^&\s]+) [NC]
RewriteRule^item/%1? [R=302,L,NE]
/* You may need to play with the above slightly... */
谷歌'阿帕奇国防部重写examples'或'现代重写引擎友好URLs' –
我很抱歉,我无法理解你在说什么。你可以请给我一些例子 –