【问题标题】:Rewriting url in apache is not working在apache中重写url不起作用
【发布时间】:2015-04-14 22:16:36
【问题描述】:

我在 ipage 服务器的 .htaccess 直接编辑器中使用以下代码来更改我网站的页面网址

例如:

http://foodinger.in/viewRestaurant.php?raipur=Barbecue-Country&id=3006

http://foodinger.in/viewRestaurant/raipur/Barbecue-Country

但它不起作用

重写引擎开启

重写规则 viewRestaurant/raipur/(.*)/viewRestaurant.php?raipur=$1&id=$2

重写规则 viewRestaurant/raipur/(.*) viewRestaurant.php?raipur=$1&id=$2

我做错了什么吗,如果我错了,请任何人建议我正确的方法? 提前致谢

【问题讨论】:

    标签: php apache .htaccess mod-rewrite


    【解决方案1】:

    您只指定一组替换(.*),它将替换目标网址中的$1

    试试:

    RewriteEngine on
    
    RewriteRule "^/viewRestaurant/raipur/(.*)/(.*)/?" "/viewRestaurant.php?raipur=$1&id=$2"
    

    并用Id查询:http://foodinger.in/viewRestaurant/raipur/Barbecue-Country/3006

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-09
    • 2011-10-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-22
    • 2020-02-26
    • 1970-01-01
    • 2016-06-21
    相关资源
    最近更新 更多