Jump to content

[SOLVED] .htaccess and Redirects


Recommended Posts

I have posted a thread like this before but still do not have a resolution. I really need some help, please!!

I have Friendly URL's turned on and generated a proper .htaccess file. It works just fine EXCEPT there is no way I have been able to figure out how to ALSO embed into the .htaccess file some Apache 2.x redirects that will work. I have an old OS Commerce site that AI want to redirect about 4000 URL's to their new PrestaShop URL.

I have tried all forms of Redirect, RewriteRule, and RedirectMatch that I could find in the Apache documentation. I have put the redirects before and after the PrestaShop generated stuff but I can't get any redirects to work at all. They either crash Apache, do nothing, or redirect back to the home page.

Some of the different forms that I have tried (one at a time) are:

Redirect 301 /index.php/cPath/475_23 http://www.motorheadextraordinaire.com/9-workbench-accessories.php'>http://www.motorheadextraordinaire.com/9-workbench-accessories.php
RedirectMatch /index.php/cPath/475_23 http://www.motorheadextraordinaire.com/9-workbench-accessories.php'>http://www.motorheadextraordinaire.com/9-workbench-accessories.php [R]

RewriteRule ^/index.php/cPath/106_107$ http://www.motorheadextraordinaire.com/11-drawer-parts-cabinets.php [R]
RewriteRule ^/index.php/cPath/106_107$ /11-drawer-parts-cabinets [R]

RedirectMatch /index.php/cPath/475_23 http://www.motorheadextraordinaire.com/9-workbench-accessories [R]
RedirectMatch /index.php/cPath/475_23 /9-workbench-accessories [R]

The two I really expected to work are the following since I hard coded the destination to the non-frieldly URL

RedirectMatch ^/index.php/cPath/106_109$ http://www.motorheadextraordinaire.com/category.php?id_category=13 [R,L]
Redirect 301 /index.php/cPath/106_110 http://www.motorheadextraordinaire.com/category.php?id_category=14

Does anyone have any idea what is going on with this problem?

Has anyone embedded their own redirects into the PrestaShop .htaccess file? If so, how did you do it?

I can really use some help on this. ANY suggestions, ideas, or words of wisdom will be greatly appreciated.

Many thanks,
Joe

Link to comment
Share on other sites

SOLVED

This was a really weird one for sure. I cut and pasted the PS friendly .htacess into a FileMaker data field (input buffer) and then used that along with the FM generated Redirects to build a new FM data field (output buffer) which is then exported to disk. FM exports in UCS-2 little endian. I then read that file into Notepad++ and changed the encoding to ANSI, which is what PS generates. When the file is saved and uploaded to the server it is in ANSI format.

I tested this by 1) comparison of byte size of PS original to PS only through my FM system and it worked, or looked like it worked okay. I was hacking back and forth between editing the original PS .htacces file in Notepad++ and also working on the FM generated file when I started to see clues of weirdness.

I then opened up a newly PS generated .htaccess file in Notepad++, deleted all of the lines, went over to FM and copied the out buffer and then pasted it into the Notepad++ clean page. I saved it, uploaded it, and it works perfectly.

There is something going on with the text file format and the sensitivity to that on my server. I'll investigate this further

The good part is I now understand how to do redirects properly with PrestaShop Friendly URL system. It works great.

Hers is a snippet of what you can put in front of the PS generated .htaccess to do Friendly Redirects. You can also use Redirect permanent and RedirectMatch directives.

# - Product Info redirects
Redirect 301 /tech_ctech.php http://www.motorheadextraordinaire.com/
Redirect 301 /tech_lista.php http://www.motorheadextraordinaire.com/content/9-lista-product-catalogs
# - PS1 - Redirects from OSC Categories
Redirect 301 /index.php/cPath/7 http://www.motorheadextraordinaire.com/2-junk-yard-specials
Redirect 301 /index.php/cPath/475_23 http://www.motorheadextraordinaire.com/9-workbench-accessories
Redirect 301 /index.php/cPath/106_107 http://www.motorheadextraordinaire.com/11-drawer-parts-cabinets
# - PS1 - Redirects from OSC Products
Redirect 301 /product_info.php/cPath/142_188/products_id/2770 http://www.motorheadextraordinaire.com/pre-rinse-potable-h2o/2232-reelcraft-3-8-inch-x35-feet-250-psi-water-reel-with-hose.html
Redirect 301 /product_info.php/cPath/142_188/products_id/2771 http://www.motorheadextraordinaire.com/pre-rinse-potable-h2o/2233-reelcraft-3-8-inch-x35-feet-250-psi-water-reel-with-hose.html

Link to comment
Share on other sites

×
×
  • Create New...