I have a site setup for a friend where I was using TCMS blog to show a list of inventory for two sets of products. So their site was: example.com/inventory/productA and example.com/inventory/productB
They’ve now downsized to just sell the one so I’ve removed productB and updated the navigation to: example.com/productA
I think I can work out how to redirect the main url but I’m not entirely sure how to make sure that existing posts get redirected. (Example, if a post is: example.com/inventory/productA/details/?permalink=url-string
how to make sure it goes to example.com/productA/details/?permalink=url-string
Is there a single rule I can put in or would I need to manually redirect all existing posts?
They only had about 20 active listings so I went and just manually redirected them. Would still be curious for the future if there’s a simple/single htaccess rule that would accomplish the above.
It should be easy enough to do with a simple RewriteRule set.
Since you are giving very generic URL examples I can’t say for sure if this would work but something like this would be a starting point:
Thanks!
I don’t know why I’m being cagey with the details.
The site is https://gilligansboats.ca/ and it once had a spot for /inventory/boats and /inventory/trailers. Now it’s just boats.
A sample blog post would be: https://gilligansboats.ca/inventory/boats/details/?permalink=2019-mb-sports-f22-tomcat-1554926454 and the new one would be: https://gilligansboats.ca/boats/details/?permalink=2019-mb-sports-f22-tomcat-1554926454
OK so if I understand, The entire trailers section is gone? you are merging the post from /inventory/trailers/details and /inventory/boats/details into /boats/details/?
To explain the first rewrite condition RewriteCond %{REQUEST_URI} ^(\/inventory/boats|\/inventory/trailers)
Simple checks the server variable REQUEST_URI ( after domain name) starts with \/inventory/boats or \/inventory/trailers, if that’s true it goes to the second rewrite condition: RewriteCond %{QUERY_STRING} ^permalink=
This one checks to see if there is a query string (stuff after ? in the URL) and that it starts with permalink=. If that is true as well then the RewriteRule is applied: RewriteRule ^(.*)$ https://gilligansboats.ca/boats/details/%1 [R=301,L]
The %1 should apply the query string as entered.
Right now the only decent tester I know about(link above) is getting a 525 error.
Only in my own mind…
The tester https://htaccess.madewithlove.be/ is back up and working.
I made a couple quick changes and tested with the one sample above: