I have about 300 redirects in the following format
Redirect 301 /post/My-Blog-Post.aspx https://www.example.com/blog/a-new-post/
That works great except the redirects are case sensitive and going to /post/my-blog-post.aspx
doesn't redirect.
There isn't a pattern for the old URL to new URL so this would likely have to be a flag for every redirect.
How can I get the URL to redirect no matter the case?
However, if you want to make "My-Blog-Post" a variable of "a-new-post", I mean if you want /post/My-Blog-Post.aspx to be redirected into /blog/a-new-post/ either /post/this.aspx into /blog/this/ or /post/that.aspx into /blog/that/ or even /post/anything.aspx into /blog/anything/, you can try to use this code in you .htaccess
hidden file:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^post/([a-z0-9-_]+).aspx$ /blog/$1/ [R=301,NC]
Don't think there's a way to make the Redirect
directive (part of mod_alias) case insensitive, but there's a mod_rewrite flag that you can use. You'll need to change all of your redirects from this:
Redirect 301 /post/My-Blog-Post.aspx https://www.example.com/blog/a-new-post/
to:
RewriteRule ^/?post/My-Blog-Post.aspx$ https://www.example.com/blog/a-new-post/ [L,R=301,NC]
Note the NC
flag, meaning "no case". This will match any URI that looks like /post/my-blog-post.aspx
and ignores case, and redirects it to https://www.example.com/blog/a-new-post/
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With