有什么想法为什么这个URL example.com/hotelinfo.aspx?idhotel=2
没有使用我的.htaccess
的以下规则重定向到这个example.com/new-url
?
Redirect 301 /hotelinfo.aspx?idhotel=2 http://www.example.com/new-url
You cannot match query string using Redirect
directive, use mod_rewrite
rules instead.
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^idhotel=2$
RewriteRule ^hotelinfo\.aspx$ http://www.example.com/new-url? [L,R=302,NC]
Once you verify it is working fine, replace R=302
to R=301
. Avoid using R=301
(Permanent Redirect) while testing your mod_rewrite rules.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.