.htaccess Htaccess重写具有特定结尾的URL

.htaccess Htaccess重写具有特定结尾的URL,.htaccess,.htaccess,我想将所有以id=111结尾的URL(例如,www.mysite.com/1/id=111,www.mysite.com/page\u id=1?id=111等)重写为www.mysite.com/pages。我该怎么做?尝试将以下内容添加到站点根目录中的.htaccess文件中 RewriteEngine on RewriteBase / $if the URL ends with id=111 RewriteCond %{THE_REQUEST} id=111\ [NC] #the

我想将所有以
id=111
结尾的URL(例如,
www.mysite.com/1/id=111
www.mysite.com/page\u id=1?id=111
等)重写为
www.mysite.com/pages
。我该怎么做?

尝试将以下内容添加到站点根目录中的
.htaccess
文件中

RewriteEngine on
RewriteBase / 

$if the URL ends with id=111
RewriteCond %{THE_REQUEST} id=111\  [NC]  
#then rewrite the request to pages
RewriteRule ^ pages [L] 
如果要将用户地址栏中的URL更改为
www.mysite.com/pages
,请将上面的最后一条规则更改为包含
R=301
,如下所示

#then redirect the request to pages
RewriteRule ^ pages? [L,R=301]