Forum Moderators: phranque

Message Too Old, No Replies

Rewrite or redirect URLS

         

okfec

4:01 pm on May 3, 2007 (gmt 0)

10+ Year Member



I have upgraded my cart (X-CART) to latest version and I have a problem with URL structure as I would like it to change.

The old stucture was:
PHP files - *.php(not blocked by robots.txt)
HTML files - replicated store with static HTML catalog in /catalog/ (for better search engine positions)
/catalog/p"productid"-"product-name".html

Now with the new version I use MOD (XC SEO) that uses MOD_REWRITE to rewrite PHP files to HTML. It puts everything to the root (I want it that way)

For instance:
/product.php?productid=11111
becomes
/canon-a640-camera

Now I would like to redirect OLD CATALOG html urls from OLD STORE to new urls MODED with MODREWRITE.

OLD URLS:
/catalog/p"productid"-"product-name".html

NEW URLS
/"product-name"-p"productid" (no ending)

Product name and productid are the same in both cases!

Due to I already have some rewrite rules in htaccess setup by XC SEO mod, should I create a map with 301 redirects, or should I rewrite those old URLS too?
I have about 7500 products.

I know I could retain the "old" product name with productid first and redirect only folder, but
my test show that products rank better with "new" style.

Thank you for your help!

P.S.
1 thing more... I could't find what [QSA,L] means. Usually i see here 301 as 301 redirect?


my curent .htaccess product rules

##### XC SEO Lite

# Rewrite SEO product URL's
RewriteRule ^([^/]*/)?[^/]+-print-c-([0-9]+)-p-([0-9]+)-pr-([0-9]+)$$1product.php?printable=Y&productid=$4&cat=$2&page=$3[QSA,L]
RewriteRule ^([^/]*/)?[^/]+-c-([0-9]+)-p-([0-9]+)-pr-([0-9]+)$$1product.php?productid=$4&cat=$2&page=$3[QSA,L]
RewriteRule ^([^/]*/)?[^/]+-print-pr-([0-9]+)$$1product.php?printable=Y&productid=$2[QSA,L]
RewriteRule ^([^/]*/)?[^/]+-pr-([0-9]+)$$1product.php?productid=$2[QSA,L]

jdMorgan

5:27 pm on May 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you should redirect your old URLs to the new SEO-friendly URLs. Because both old and new URLs contain the same information, you will be able to do this using only s few redirects -- You certainly won't need 7500!

The QSA and L flags are documented in the RewriteRule [httpd.apache.org] section of the mod_rewrite documentation. Please don't attempt to use mod_rewrite without reading that document! It appears that you may be able to use the simpler RedirectMatch [httpd.apache.org] directive from mod_alias if mod_rewrite is too daunting for your taste.

Jim

okfec

10:00 pm on May 3, 2007 (gmt 0)

10+ Year Member



RedirectMatch 301 /catalog/p([0-9]{1,7})-(.*).html http://www.example.com/TEST/$2-pr-$1

I came up with this... and it works :) Thnx

[edited by: jdMorgan at 2:20 am (utc) on May 4, 2007]
[edit reason] example.com [/edit]

jdMorgan

2:19 am on May 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can speed things up a bit by anchoring the pattern, by using a less-ambiguous second subpattern, and by escaping the literal period -- Unescaped, a period means "any single character" to regular-expressions.

RedirectMatch 301 ^/catalog/p([0-9]{1,7})-([^.]+)\.html$ http://www.example.com/$2-pr-$1

On a lot of sites, this won't make much of a difference, but since you've got hundreds of URLs to redirect, it's likely you've also got significant traffic, so this may help.

Jim