我需要重定向
http://example.com/page/?Id=1253-23098-
到
http://example.com/page/1253-23098
此重定向还包括删除' - '从查询字符串的结尾。
我所做的是
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/page/$
RewriteCond %{QUERY_STRING} ^Id=([0-9\-\0-9]*)$
RewriteRule ^(.*)$ http://example.com/page/%1? [L,R=301]
将我重定向到
http://example.com/page/1253-23098-
我需要在" 1253-23098"之后删除任何内容。来自我的查询字符串。
我从最后3-4个小时开始搜索它,但似乎没什么用。 任何帮助表示赞赏。
答案 0 :(得分:1)
尝试:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/page/?$
RewriteCond %{QUERY_STRING} ^Id=([0-9]*)-([0-9]*)-$
RewriteRule ^(.*)$ http://example.com/page/%1-%2? [L,R=301]
答案 1 :(得分:1)
您可以使用:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^Id=(\d+-\d+) [NC]
RewriteRule ^page/?$ page/%1? [NC,L,R=301]