Totally Zenned
- Join Date:
- Apr 2010
- Posts:
- 900
- Plugin Contributions:
- 0
Using htaccess to redirect legacy links. Need help!
Hi,
I have a site that I monitor with Google Webmaster. I built the site like two years ago. A few weeks ago, the console began alerting me to an increase of 404 Not Found Errors. In the console, I drilled into the links to find the source. Google was claiming that many of the non-existing links were coming non-existing pages.
Further study showed that the links not being found did exist, before I switched over to ZC. And I was able to find some external websites that were linking in to my site, using the now ancient/non-working url's.
SOLUTION: I decided to build a redirect tree into the htaccess for the old sitemap.
But this seems to be creating even more problems! :(
This site, btw, uses Ceon URI and that is the only other content of the htaccess file. Here is that code:
## BEGIN CEON URI MAPPING REWRITE RULE
RewriteEngine On
# Don't rewrite any URIs ending with a file extension (ending with .[xxxxx])
RewriteCond %{REQUEST_URI} !\.[a-z]{2,5}$ [NC]
# Don't rewrite any URIs for some, popular specific file format extensions,
# which are not covered by main file extension condition above
RewriteCond %{REQUEST_URI} !\.(mp3|mp4|h264)$ [NC]
# Don't rewrite any URIs for some specific file format extensions,
# which are not covered by main file extension condition above
# Uncomment the following line to apply this condition! (Remove the # at the start of the next line)
#RewriteCond %{REQUEST_URI} !\.(3gp|3g2|h261|h263|mj2|mjp2|mp4v|mpg4|m1v|m2v|m4u|f4v|m4v|3dml)$ [NC]
# Don't rewrite admin directory
RewriteCond %{REQUEST_URI} !^/admin_S2g6 [NC]
# Don't rewrite editors directory
RewriteCond %{REQUEST_URI} !^/editors/ [NC]
# Don't rewrite logs directory
RewriteCond %{REQUEST_URI} !^/logs/ [NC]
# Handle all other URIs using Zen Cart (its index.php)
RewriteRule .* index.php [QSA,L]
## END CEON URI MAPPING REWRITE RULE
There are two types of links in my legacy sitemap:
- straight forward links and 2) links that contain regular expressions
I can get the straight links to give a 301 instead of a 404 by simply adding this below Ceon rewrite (currently 125 lines of this re-map):
Redirect 301 /Hakko_HJ5000_Heat_Gun_1300w_Dual_Temp_RC_Skin_B /index.php
Redirect 301 /prod-HAKKO_FX_8804_Hot_Tweezer-347.aspx /Hakko_950_Hot_Tweezer_Conversion_Kit_w_Holder
Redirect 301 /cat-Extraction_Kits-76.aspx /Fume_Dust_Extraction/Extraction_Systems
Redirect 301 /cat-Flux_and_Cleaners-27.aspx /Solder_Fluxes_Chemicals/Fluxes
Redirect 301 /cat-General_Purpose_Tweezers-51.aspx /General_Purpose_Tweezers_7
Redirect 301 /pdf/DesiccantRegeneration.pdf /download/ppk_pdf/DesiccantRegeneration.pdf
The problem is... I can't figure out how to get links in the second category to be treated literally. Here are some examples:
Redirect 301 /search.aspx?advanced=1 /index.php
Redirect 301 /pdf/48950%20Drawing.pdf /PROTEKTIVE_PAK_48950_BAG_PROTECTIVE-SHIELD_MBB_4_MIL_10INx20IN_100_EA_PACK
Redirect 301 /pdf/TDS_NC%20251%20Sn62%20&%20Sn63%20Solder%20Paste.pdf /index.php
Redirect 301 /detail.aspx?ID=124 /index.php
Redirect 301 /detail.aspx?ID=75 /index.php
Redirect 301 /detail.aspx?ID=80 /index.php
Can somebody please show me how to rewrite links like the ones above, such that the legacy link will be treated literally?
And yes, I know a blank space in a file name (%20) is bad form. But that is legacy, not my doing!