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
-
HSTS Redirects
Hi Are these 307 redirects bad for SEO? They've just popped up on an audit & I haven't seen them before. I'm guessing as they're temporary they should be updated. Thanks Becky
Intermediate & Advanced SEO | | BeckyKey0 -
Should I redirect off topic blog posts?
We launched a store on top of a popular blog. The blog had nothing to do with the store. The blog has a lot of backlinks and traffic, but our store is now our primary business. I am concerned that the off topic blog content may be affecting or ability to rank better for the core store business. Should we delete or redirect the old blog content to another website to improve the SEO for our store?
Intermediate & Advanced SEO | | seo-mojo1 -
301 Redirecting from domain to subdomain
We're taking on a redesign of our corporate site on our main domain. We also have a number of well established, product based subdomains. There are a number of content pages that currently live on the corporate site that rank well, and bring in a great deal of traffic, though we are considering placing 301 redirects in place to point that traffic to the appropriate pages on the subdomains. If redirected correctly, can we expect the SEO value of the content pages currently living on the corporate site to transfer to the subdomains, or will we be negatively impacting our SEO by transferring this content from one domain to multiple subdomains?
Intermediate & Advanced SEO | | Chris81980 -
Redirecting an IP address
Just taken over a new client who recently moved from A.N. other platform to Shopify. I just found reference to their old website IP address and it appears to be not redirecting. Can I simply use something like Traffic Control (Shopify app) to redirect to the new domain?
Intermediate & Advanced SEO | | muzzmoz0 -
301 redirect and improved ranking
I was wondering if a 301 redirect will improve my ranking. My subpages use to redirect to my homepage ( all the subpages of my site redirecting to my homepage) and my homepage use to have no redirect from non www.to www. ( other than thru google webmaster tools. I am sure why it was like this for my subpages... I was wondering if I can expect some improvements in ranking now that the redirect goes from the none www. to the www version of each subpage and not to the homepage. By the way what was the issue ( was I telling google ) by re-directing all my subpages to the homepage ? was I making google think that my subpages and my homepage were all the same ? was I sending all the link juice from the subpages to my homepage ? etc... Thank you,
Intermediate & Advanced SEO | | seoanalytics0 -
Should I redirect secondary keyword page
I have a reasonably high authority home page and have decided to optimise the home page to target a competitive keyword that previously had a specific page that was optimised on an internal page of my site that I have spent time building links to. The internal page has over 200 links to it so should I 301 redirect this internal page to the home page. Will that increase the auhority of the home page further? Or should I keep the internal page as a 'secondary' page for that keyword?. If I do have two pages don't I risk confusing google?
Intermediate & Advanced SEO | | SamCUK0 -
Move to a new domain - How to get the redirects right?
Hi, I hope that someone with good htaccess knowledge can help. I am planning on moving my site to a new domain. I understand that I should make 301 redirects using htaccess for every URL. This is a big site so it will be impossible to not forget some of the thousands existing URLs. Now to the question: How do I make all the URLs that is not specified in htaccess to redirect to my new root? Thanks!
Intermediate & Advanced SEO | | mrlolalot0