1

Can any check given code of .htaccess file and let me know what's wrong with it and why it's not working?

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^itinerary/([a-zA-Z0-9_-]+)/([0-9]+)\$ itinerary-details.php?tId=$2

I want to rewrite url as below:

www.domain.com/itinerary-details.php?tId=2&tName=agra-delhi-tour

to

www.domain.com/itinerary/2/agra-delhi-tour


and

www.domain.com/itinerary-details.php?page=1&tId=2&tName=agra-delhi-tour

to

www.domain.com/itinerary/2/agra-delhi-tour/1

Please help me in doing this.

Thanks

4

2 回答 2

0

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^itinerary/([^/]+)/([^/]+)/?$ /itinerary-details.php?tId=$1&tName=$2 [L,QSA,NC]

RewriteRule ^itinerary/([^/]+)/([^/]+)/([^/]+)/?$ /itinerary-details.php?page=$3&tId=$1&tName=$2 [L,QSA,NC]
于 2012-06-09T06:57:57.840 回答
0

似乎您的正则表达式中的两个部分颠倒了。这应该适用于您的两种情况:

^itinerary/([0-9]+)/([a-zA-Z0-9_-]+)/?(.*) itinerary-details.php?tId=$1&tName=$2&page=$3

我也刚刚注意到您正在逃避,$这也会导致问题。

于 2012-06-09T06:19:36.560 回答