Redirecting a working dynamic URI to a new static format
-
Hi all
I am having some issues rearding url rewrites and 301 redirects with 1 and 1 hosting and am unsure of the best approach. The website is a custom made shopping cart system with categories and products.
The current urls for categories are : index.php?l=product_list&c=1 The new url format required is : /banner-stands
After a little bit of research I added the following into the htaccess file;
Options +FollowSymlinks
AddType x-mapp-php5 .phpRewriteEngine On
RewriteBase /
RewriteRule ^banner-stands/?$ index.php?l=product_list&c=1 [R=301,NC,L]
Which works but I have a few questions
Question 1: Is this the best approach as there are 55 categories and 179 products to write redirects for
Question 2: Or is it better to firstly add id=banner-stands into the url and then create 301 redirects to the new url and then rewrite the url.
Thanks
-
This is what I would do:
.htaccess
Options +FollowSymLinks -Multiviews -Indexes
RewriteEngine On#This line is for the categories
RewriteRule ^category/(.*)$ index.php?l=product_list&category_name=$1 [L]Note: you will need a new rule for each "type" of page. That was an example for the categories only.
Then you will need to add some PHP code to read the $_GET["category_name"] variable, which should be text (like banner-stands) and get the category id from your database to later load the products. You have several ways to do that, for example: insert an extra column in the DB with the category name "dashed" and search the category id using that new field.
You should then change your internal linking to use those new URLs instead and add a rel=canonical pointing to the new versions of the URLs.
Don't 301 all others until you have the above solved and working. Make sure you make everything safe, as with that structure something like index.php?l=product_list&c=1&sort=asc won't work anymore unless you create extra rules for that, same as with pagination, if you have any.
Hopes this gives you an idea on where to start.
***You are not redirecting dynamic to static urls, you are just making them friendlier
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
-
Redirect Juice?
Hello all! I have a partner site that is linking their product page (step 1) to our product page (step 2) and then we instantly forward them to our shopping cart page (step 3) with that product added. Will my product page (step 2) get the SEO juice from our partners link (step 1) even though we instantly forward to our shopping cart page (step 3)? Curious about ways to technically do this correctly. Thank you!
Intermediate & Advanced SEO | | Jamesmcd030 -
Should I revive the old domain or just redirect all the juicy links to my new site?
I'm about to acquire a domain with a lot of great/highly authoritative backlinks. The links pointing to the domain are quite powerful and the domain is an exact match TLD. I have two options (that I know of 😞 1. I could redirect all the links to their new home(s) on my new site which offers the same resources the old site used to offer. or 2. I could rebuild the tools/content on this site. Ideally, I'd transfer to my new site as all those powerful links could help all my rankings. However, I'm worried that some of the powerful links will de-link once they see the site redirects elsewhere, even though it's offering the same content. Also, option one isn't an exact match domain. Which, I know, shouldn't make a difference now-a-days but regardless of what people say, it still seems to help out some sites in less competitive niches. One more thing to note: The domain that I'm purchasing is about 25 years old. I'm leaning toward option one. I want to make sure I put my best foot forward on this investment and thought it wise to consult the SEO gods.
Intermediate & Advanced SEO | | ninel_P0 -
Should I redirect images when I migrate my site
We are about to migrate a large website with a fair few images (20,000). At the moment we include images in the sitemap.xml so they are indexed by Google and drive traffic (not sure how I can find out how much though). Current image slugs are like:
Intermediate & Advanced SEO | | ArchMedia
http://website.com/assets/images/a2/65680/thumbnails/638x425-crop.jpg?1402460458 Like on the old site, images on the new website will also have unreadable cache slugs, like:
http://website.com/site_media/media/cache/ce/7a/ce7aeffb1e5bdfc8d4288885c52de8e3.jpg All content pages on the new site will have the same slugs as on the old site. Should I go through the trouble of redirecting all these images?0 -
Redirect help
I work for a company that has a domain that is something like www.neat-stuff.com but most people just use www.neatstuff.com without the dash. The redirect for the homepage works fine. We recently launched a new site and if you use www.neat-stuff.com/category it redirects from the old site to the new site just fine. However if you use www.neatstuff.com/category it does not properly redirect to www.neat-stuff.com/category. How do I fix that?
Intermediate & Advanced SEO | | EcommerceSite0 -
Launching a new site with old, new and updated content: What’s best practice?
Hi all, We are launching a new site soon and I’d like your opinion on best practice related to its content. We will be retaining some pages and content (although the URLs might change a bit as I intend to replace under-scores with hyphens and remove .asp from some extensions in order to standardise a currently uneven URL structuring). I will also be adding a lot of new pages with new content, along with amend some pages and their content (and amend URLs again if need be), and a few pages are going to be done away with all together. Any advice from those who’ve done the same in the past as to how best to proceed? Does the URL rewriting sound OK to do in conjunction with adding and amending content? Cheers, Dave
Intermediate & Advanced SEO | | Martin_S0 -
Redirects 301
Hello guys, I have a doubt. If I reedirect a url with a pagerank of 2 to a new URL, will I loose the PR? My problem is that I have a long url in one page wich is not effective to target a keyword that Im persuing. Im climbing in Google, however I want to 1º place and I dont think that with this long URL I will make it. Advices? Cheers! Pedro M Pereira
Intermediate & Advanced SEO | | PedroM0 -
How long should a domain redirect take?
Hi, I know that this is a 'How long is a piece of string?' type question but at what point should the ranking value of site A pass over to site B following a domain 301 redirect? I have shifted a domain over to a new URL, same hosting server, same IP address. I haven't made any URL changes or any content changes other than to change the site logo to match the new domain name. Domain B is basically an exact clone of domain A. I have redirected Domain A to domain B using the following line at the top of the .htaccess file:- Redirect 301 / http://www.newdomain.com/ I have submitted a sitemap for the new domain via google webmaster tools. It looks like the original domain as been completely indexed by google following the redirect as all rankings have been dropped from the results and there are no results for a site:olddomain.com search. Surely the rankings should have switched over at this point? Any help would be much appreciated.
Intermediate & Advanced SEO | | AdeLewis
Ade.0