homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Mass 301 redirect help

 5:26 pm on May 11, 2013 (gmt 0)

I've not seen an answer for this mass 301 redirect issue specifically... Can anyone let me know how to do this....

category/brand URLs:

redirect: /ID-some-brand (e.g. /43-religion-clothing or /26-ichiban) to: /some-brand (e.g. /religion-clothing or /ichiban)

Product URLs:

redirect: /some-category/ID-some-product-name.html (e.g. /mens-sweat-shirts/1543-ichiban-fairly-offensive-sweat-in-grey.html)

to: /some-product-name (e.g. /ichiban-fairly-offensive-sweat-in-grey)

We have 1,090 products and 60+ categories so some form of .htaccess trick would be amazing to know. If anyone could provide me with what I could put in the .htaccess to accomplish this I would be eternally grateful!



 6:43 pm on May 11, 2013 (gmt 0)

This sounds like a run-of-the-mill rewrite/redirect. Take a look at

- or -

for examples.


 8:04 pm on May 11, 2013 (gmt 0)

I've not seen an answer for this mass 301 redirect issue specifically

Well, no, you're not going to find a thread that says how to redirect the exact URL
to the exact URL

But there are hundreds of posts detailing RewriteRules that will do the trick.

If you already use mod_rewrite (RewriteRule by that name, regardless of what it does) then any redirects in the same htaccess also need to use mod_rewrite.

If not, you can use mod_alias in the RedirectMatch form. You need RedirectMatch (or RewriteRule) rather than simply Redirect because you'll be setting up a simple Regular Expression and capturing part of the request.

Based on your examples, it looks as if both types of redirect can be collapsed into a single rule.

But now...
redirect: /some-category/ID-some-product-name.html (e.g. /mens-sweat-shirts/1543-ichiban-fairly-offensive-sweat-in-grey.html)

to: /some-product-name (e.g. /ichiban-fairly-offensive-sweat-in-grey)

Was that cut short for faster typing, or are you really planning to go extensionless? If so, you will need a second rule or ruleset to go from the new URL to where the content really lives.

Come to that: Are you really changing-- or have you already changed-- the names of the physical files and directories? Or are you just changing the URLs?

A change in filename doesn't mean you have to change the URL. But if the end result is shorter and prettier, it's probably the right way to go.


 10:00 am on May 12, 2013 (gmt 0)

I'm not able to figure out how to write the redirect expressions. Are you able to help me out massively? We are meant to be switching to our new site this evening.

And secondly, it wasn't cut short - Prestashop use the .html extension for product URLs and Opencart doesn't.

We haven't switched over yet. I'd like to have the .htaccess setup to redirect before the switch. The reason for switching is because Prestashop is poor/keeps crashing the servers/doesnt have cheap mobile framework.

So if you could help me out by writing what I'd need, I'd even be happy to send over a small donation.


 6:28 pm on May 12, 2013 (gmt 0)

For now I've installed a mod that sends the user to the search results page pulling out the keywords from the URL that would normally produce a 404 error.

It's not really possible to test htaccess stuff when the new site isn't on the same domain yet - that's happening tonight.


 9:18 pm on May 12, 2013 (gmt 0)

Prestashop use the .html extension for product URLs and Opencart doesn't.

Oh now wait. So you're also redirecting to a different domain? In one way this makes it easier, because you don't have to keep track of rule ordering; the rewrites will happen in a completely different place. That's assuming the new domain is also on a different server, or at least in a different userspace in shared hosting, so requests for the two domains will never pass through the same htaccess.

The bad news is that WebmasterWorld doesn't write people's code for them. We're more about helping people learn how to do things for long-term benefits. You might try That Other Forum. They seem to be correct more than half the time.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved