简体   繁体   English

在Apache中重写URL不起作用

[英]Rewriting url in apache is not working

I am using the following code in .htaccess direct editor in ipage server for changing my website's page url from 我正在ipage服务器中的.htaccess直接编辑器中使用以下代码来更改我的网站的页面网址,

for example: 例如:

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

to

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

but it is not working 但它不起作用

RewriteEngine on 在RewriteEngine上

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

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

Am i doing anything wrong, Please anyone suggest me the right way if i am wrong ? 我做错什么了,如果我做错了,请有人建议我正确的方法吗? Thanks in advance 提前致谢

You specify only one group for substitution (.*) that will replace $1 in target url. 您仅指定一组替换(.*) ,它将替换目标url中的$1

Try: 尝试:

RewriteEngine on

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM