I am trying to redirect a few old URLs to new ones using htaccess, which rewrites a GET query in my PHP file to clean URLs:
Options +FollowSymLinks
RewriteEngine on
RedirectMatch 301 /photo/old-photo /photo/new-photo
RewriteRule ^photo/(.*)/?$ tpl-photo.php?slug=$1
RewriteRule ^photo/(.*)?$ tpl-photo.php?slug=$1
This outputs my clean URLs correctly like so:
http://website.com/photo/one-beautiful-photo
However, when I try to redirect my old URLs to new URLs, it somehow messes up the URL:
http://website.com/photo/new-photo?slug=old-photo
How can I correct this so that I get a proper clean new URL:
http://website.com/photo/new-photo
Don't mix mod_rewrite
and mod_rewrite
rules and keep only mod_rewrite
rules like this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^photo/old-photo/?$ /photo/new-photo [NC,L,R=301]
RewriteRule ^photo/([^/]+)/?$ tpl-photo.php?slug=$1 [L,QSA,NC]