Reputation: 13
I need to 301 redirect all ?print=yes
URLs to the URLs without ?print=yes
that contain the same name in them through .htaccess
. Currently the button to PRINT
is present in the header of the website so it's more than 70 URLs to fix... Removing the button to PRINT
the page will ruin the design quite a bit, so it's not really an option.
I think it needs to be a RedirectMatch
rule, but how do I write it?
Example: redirect 301 from domain.com/faq/?print=yes to domain.com/faq
Thanks in advance!
Upvotes: 1
Views: 113
Reputation: 786289
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^print=yes$ [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L,NE]
Upvotes: 1
Reputation: 1469
I am not sure if redirect can do the same but here is how I would do it with rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\?print=yes$ $1 [NC]
Upvotes: 0