简体   繁体   中英

Parameters before '?' in mod_rewrite

I have a URL like this:

/gallery/page.php?id=object

And I want to redirect this page to another page.

Using mod_rewrite, how can I redirect this URL?

I Try this:

RewriteCond %{QUERY_STRING} ^id=object$ [NC]
RewriteRule ^gallery/page.php/?$ http://www.mysite.com/gallery/page.php?id=new [R=301,L,NE]

But this doesn't work fine.

Thanks in advance

put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} (^|&)id=object(&|$) [NC]
RewriteRule ^(gallery/page\.php)$ /$1?id=new [R=301,L,NC]

Reference: Apache mod_rewrite Introduction

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM