简体   繁体   中英

remove a query string in htaccess 301 redirect

I have URL like these:

/one/two?page=1
/three/four/five?page=2

I need to remove "page=1" and redirect it to /one/two but only when "page=1" appears, not "page=2".

How can i do that?

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^page=1$ [NC]
RewriteRule %{REQUEST_URI}? [L,R]

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