Forum
Blog rewrites interfering with 301
Hello,
I've updated a blog slug format from %Y-%m-%d-{postTitle} to remove the date to be {postTitle}
All working well but after putting 301s in place to redirect the old urls with the date to the new urls
Redirect 301 /blog/2016-03-16-post-title https://site.com/blog/post-title
The redirects result in
https://site.com/blog/post-title?s=2016-03-16-post-title
I'm assuming this line from the htaccess is interfering with it:
RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
How can I amend the above without breaking it?
Which order do you have the rules in?
Followed by the 301s.
I have switched them to test but not change.
Ok, here's something I didn't know.
mod_rewrite
rules get executed beforemod_alias
(Redirect
) rules, regardless of the order in which they appear.So if your old URL matches the rewrite rule, then it'll get rewritten before the Redirect tries to match it.
I think in this case it might be simpler to use
mod_rewrite
for both.Thanks for this! I was having this issue, too, and this fixed my problem.