htaccess规则忽略url上的一些字符串

时间:2013-06-26 10:44:48

标签: .htaccess

需要帮助

我有这样的链接

http://www.mysite.com/obj/task/land/city/41277/landId/19/Best+Restaurant//Sville%20city

使用htaccess

RewriteRule ^l/([0-9]+)/([0-9]+)/?$ index.php?obj=obj&task=land&city=$1&landId=$2
RewriteRule ^l/([0-9]+)/([0-9]+)$ index.php?obj=obj&task=land&city=$1&landId=$2

现在我的链接看起来像这样

 http://www.mysite.com/l/41277/19

我应该在我的htaccess上添加什么,以便我接受这样的链接

http://www.mysite.com/l/41277/19/Best+Restaurant//Sville%20city
http://www.mysite.com/l/41247/17/Best+parks/Cold%20Province/Platinum%20city

1 个答案:

答案 0 :(得分:1)

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

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^l/([0-9]+)/([0-9]+)/? /index.php?obj=obj&task=land&city=$1&landId=$2 [L,QSA,NC]