Summary: I've been asked to migrate a .asp site over to Wordpress, but I'm having some issues with the .htaccess redirects.
What I'm trying to Achieve:
Pages:
domain.com/Some-Page-On-My-Site.asp
redirects too
domain.com/some-page-on-my-site/
Posts:
domain.com/articles.asp?title=The-Greatest-Post-Title
redirects too
domain.com/blog/the-greatest-post-title/
End Goal
- Stay consistent with default Wordpress permalink structure using lowercase.
- Convert only the .asp URL requests to lowercase not the rest of the site.
I'm thinking that because of the *.asp pages redirect that it may be sucking in the articles.asp and converting it to /articles/ . So I swapped their spot in the .htaccess file.
I'm thinking that RewriteCond and Skip Flag is probably required for this to work. But could be wrong.
I'm glad I was able to get the Pages redirect to work, although I think there is just a little more to make these work better.
What I've tried
This converts URL Requests for old .asp pages to new URL Structure:
RewriteRule ^(.*)\.asp$ /$1/? [L,R=301]
These attempts do not convert URL Requests for old .asp posts:
# Try 1
RewriteRule ^articles\.asp?title=(.+)$ /blog/$1/ [L,R=301]
# Try 2
RewriteRule ^articles\.asp?title=(.*)$ /blog/$1/ [L,R=301]
# Try 3 - Not that this would probably work but was an attempt
RewriteCond %{QUERY_STRING} (^|&)title\=(.+)($|&)
RewriteRule ^articles\.asp$ /blog/$1/? [L,R=301]
I confirmed that I can do 1-to-1 redirects, but not similar to the Pages structure like above where I can type anything before .asp and it just removes the .asp
RewriteCond %{QUERY_STRING} (^|&)title\=Duck\-Feet\-Wine($|&)
RewriteRule ^articles\.asp$ /blog/duck\-feet\-wine/? [L,R=301]
Does anyone have some insight on this? or am I crazy to think that I can do this?
I've read about 100+ pages and I'm stumped, including stumped on how RewriteCond works. I happy that I was able to get the pages redirect to work, now to convert a query string to a static like link to work with Wordpress's lowercase permalink structure.