Changing permalinks in new wordpress website using regex in 301s?
-
Hi there
I am working on a website and we would like to change the permalinks from product-category (replacing with Shop) and product to buy. Currently there are nearly 400 products and multiple categories.
Although the website has just been indexed wondering if we need to do 301's? if we did would like to use regex to manage
so redirect would be as example: mydomain.com/sub-domain/product-category/ redirecting to to mydomain.com/sub-domain/shop/ (I know you do not need to put in the domain but as an example) - could anyone give me the regex for this?
Same for products: mydomain.com/sub-domain/product/sample-product redirect to mydomain.com/sub-domain/buy/sample-product
thanks in anticipation
-
You're welcome. Hope it worked out for you. You can mark this as answered if the problem is solved.
-
Thanks so much for your responses. Will try that now
-
Hello Allie,
Here is the basic regex redirect code to place in your htaccess file.
RedirectMatch 301 /sub-folder/product-category/(.) /sub-folder/shop/$1
RedirectMatch 301 /sub-folder/product/(.) /sub-folder/buy/$1Hope this helps. You can also find more information on redirecting old pages using regex from WPEngine here.
-
Hi Allie,
Sounds like you've got two questions:
First, you'll need to use 301s if you have any inbound links to the pages that you're replacing.
Second, you can't use Regex in HTML. Do you have a CMS that can help you build the 301s?
Best,
Kristina
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
If I change Tags and Categories in Wordpress blog post, will it negatively affect SEO and cause 404s?
Hi, I have belatedly come to the conclusion that I have been using tags and categories when blogging in wordpress incorrectly. The result is that Google seems to prefer to show my archives and tags in search results rather than the post itself. Not good UX. As the site is only a few months old, am I best to learn my lesson and tag and categorize correctly moving forward or Should I go back in to these posts and clean them up & categorize and tag correctly. If I do this, will it cause 404s and hurt my SEO? Thanks!
Technical SEO | | johnyfiveisalive2 -
Permalink change
what will happen with the old permalink when we change the title name to a new title name? would the old permalink disappear after a while or i have to manually delete them? thank you
Technical SEO | | gergi0 -
How do I optimize a website for SEO for a client that is using a subdirectory as a seperate website?
We launched a subdirectory site about two months ago for our client. What's happening is searches for the topic covered by the subdirectory are yielding search results for the old site and not the new site. We'd like to change this. Are there best practices for the subdirectory site Specifically we're looking for things we can do using sitemapping and Webmaster tools. Are there other technical things we can do? Thanks you.
Technical SEO | | IVSeoTeam120 -
Canonical & rel=prev / next changes to website a good idea or not?
Hi all, I decided yesterday to make a load of changes to my website, and today i woke thinking, should i have done that! So below is an example of what i have done (i will try to explain clearly anyway), can you let me know if you think what i have done would harm or help my website in search results etc... ok, so lets take just one category - Cameras And it has the sub categories - box dome bullet it also has other sub categories (which are actually features, but the only way i can show them on my site is by having them as a sub-category with its own static page, and adding the products to these as secondary categories) vandal proof high resolution night vision previously i have it set up so that every single category / sub category / feature had its own static page, with a canonical tag to itself (i.e cameras.html canonical was to cameras.html, vandalproof.html canonical was to vandalproof.html). Any of the categories / sub cats / features that had more than one page were simply not in search results due to the canonical pointing to "Page 1"... What i have now done: Last night i decided to change all this, now for all categories / sub cats / features i have add rel=prev / next where applicable, and removed the canonical from second / third / fourth pages etc, but left the canonical on "page 1". I also removed any keywords from page 2,3,4 etc and changed descriptions to just page "X" + category name. So for example, page one looks like: and page two looks like: I also went a little further (maybe too far) and decided that the features pages would canonicalize back to cameras so for those i now have: Page 1: Page 2: Any advice is welcome on the above, in regards to which way may be better and why, and obviously if anything jumps out as a mistake... Please advise James
Technical SEO | | isntworkdull0 -
What is "evttag=" used for?
I see evttag= used on realtor.com, what looks to be for click tracking purposes. Does anyone know if this is an official standard or something they made up?
Technical SEO | | JDatSB0 -
Why is an error page showing when searching our website using Google "site:" search function?
When I search our company website using the Google site search function "site:jwsuretybonds.com", a 400 Bad Request page is at the top of the listed pages. I had someone else at our company do the same site search and the 400 Bad Request did not appear. Is there a reason this is happening, and are there any ramifications to it?
Technical SEO | | TheDude0 -
How do I use only one URL
my site can be reach by both www.site.com and site.com. How do I make it only use www?
Technical SEO | | Weblion0 -
New Ecom Category
Hello, I'd like to create a new category for my store. All products will be from other categories, no new products will be added. So this is really content that is already on my site. I will add cateogry specific text in this page with unique title, etc. But the products are all already on my site.Is this duplicate content, will this be a bad move? Thanks
Technical SEO | | tylerfraser0