Link to home
Start Free TrialLog in
Avatar of udk1
udk1Flag for Germany

asked on

Redirect to catagorie in case of 404

Hello,
our webshop is for hand crafted beads: each one is a unique item. Often this beads are found in google image search - nice, but when the item is sold this leads to a 404...
Is it possible to redirect to the folder/categorie containing similar products?
Example:
htttp://myServer.com/shop/categorie1/product99.html -> htttp://myServer.com/shop/categorie1/

Thank you for help!
udk
ASKER CERTIFIED SOLUTION
Avatar of Dr. Klahn
Dr. Klahn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of udk1

ASKER

Thank you Dr. Kahn!
Sorry, for not responding a while...
Your suggestion looks good. To bring it to my server I would like to ask some questions for deeper understanding - sorry, productive system... ;-)
It has to be inserted into the .htaccess ...
! negates a comparison result.
 -s checks whether it is a file with size greater 0, -l symbolic link and -d directory. Ok?
All three conditons have to be true to come to the fourth comparison...

I found I already have .htaccess file with rules inside :-(
This contained rule for me seems relevant for the things I wanded to do:
Although I do not understand it complete it seems the way I expected to solve my problem will not work?
##boosted PRODUCTS
RewriteRule (^[a-z]{2})/(.*/)?([A-Za-z0-9_-]+)\.html product_info.php?language=$1&gm_boosted_product=$3&%{QUERY_STRING} [PT,L]
RewriteRule (.*/)?([A-Za-z0-9_-]+)\.html product_info.php?gm_boosted_product=$2&%{QUERY_STRING} [PT,L]

Open in new window


Hm, it seems the path of a product it's categories, subcategories and html-files is generated by request with PHP-code of the shop software.
So my question was wrong - my 404 page is not the "There are no search results. Would you like to search again?" - page...
This is the page the shop software is returning...

Can you suggest a solution for that? As I understand the shop software has to be adapted, or is there another way?
Avatar of Dr. Klahn
Dr. Klahn

I don't use .htaccess files, as they make a site difficult to support.  When there are .htaccess files scattered all over it's difficult to tell what is causing a problem.  imo, better to write a very specific rule that applies only to one folder and put the rule in httpd.conf.
Avatar of udk1

ASKER

Althought it is not working for me the solution is a great hint how to use Rewrite...