Yeah,
looking at it closer I see the issue. You are redirecting a page with an HTML query string attached( the Stuff following the ?
). That dynamically generated address probably can’t be handled by a “single line” redirect rule but would need a more complete RewriteRule to handle the query string. So there are a number of ways to handle that.
Some questions are you keeping the “query string” (stuff after the ?
) the same on the new page?
if so a single rule set should work:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^\/blog
RewriteCond %{QUERY_STRING} ^post_id=([0-9]*)
RewriteRule ^(.*)$ https://www.themagiccrayons.com/newblog/%1 [R=301,L]
The above would redirect as the following:
Entered URL:
https://www.themagiccrayons.com/blog/?post_id=199&title=cats.html
Should get redirected to:
https://www.themagiccrayons.com/newblog/199?post_id=199&title=cats.html
Entered URL:
https://www.themagiccrayons.com/blog/?post_id=133&title=how-a-car-engine-works
Should get redirected to:
https://www.themagiccrayons.com/newblog/133?post_id=133&title=how-a-car-engine-works
Are you wanting to change to A URL without a query string(no ?
)?
If so the rules become more complicated. You will need to specify a rule group for each page(post). this example shows 2 posts (199 & 133)
RewriteEngine On
RewriteCond %{REQUEST_URI} ^\/blog
RewriteCond %{QUERY_STRING} ^post_id=199
RewriteRule ^(.*)$ https://www.themagiccrayons.com/newblog/new-post199/? [R=301,L]
RewriteCond %{REQUEST_URI} ^\/blog
RewriteCond %{QUERY_STRING} ^post_id=133
RewriteRule ^(.*)$ https://www.themagiccrayons.com/newblog/new-post133/? [R=301,L]
Entered URL:
https://www.themagiccrayons.com/blog/?post_id=199&title=cats.html
Should get redirected to:
https://www.themagiccrayons.com/newblog/new-post199/
Entered URL:
https://www.themagiccrayons.com/blog/?post_id=133&title=how-a-car-engine-works
Should get redirected to:
https://www.themagiccrayons.com/newblog/new-post133/
Are you wanting to change to A URL with a NEW query string)?
Again very similar to above need a sele set(3 lines) for each post. Just put the query string after the ?
.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^\/blog
RewriteCond %{QUERY_STRING} ^post_id=199
RewriteRule ^(.*)$ https://www.themagiccrayons.com/newblog/?this-is-the-new-query-199 [R=301,L]
RewriteCond %{REQUEST_URI} ^\/blog
RewriteCond %{QUERY_STRING} ^post_id=133
RewriteRule ^(.*)$ https://www.themagiccrayons.com/newblog/?this-is-the-new-query-133 [R=301,L]
Entered URL:
https://www.themagiccrayons.com/blog/?post_id=199&title=cats.html
Should get redirected to:
https://www.themagiccrayons.com/newblog/?this-is-the-new-query-199
Entered URL:
https://www.themagiccrayons.com/blog/?post_id=133&title=how-a-car-engine-works
Should get redirected to:
https://www.themagiccrayons.com/newblog/?this-is-the-new-query-133
The page exists just not the post.