View Full Version : Newbie -- htaccess question

Apr 16th, 2009, 10:08 PM
Hi (first post)

I would like to use htaccess to direct 404 traffic to the index page of a site I am very new at this. The site has access to cPanel which offers the ability to modify the 404 response(s) I have never done this before however. Currently 98% of the traffic is 404ed away from the sites. Also I am told that my hosting service should be contacted.

I would like to do the following (XXX are page numbers):

http://www.akilo.com/main-1_000XXX.html redirected to http://www.babysafari.us


http://www.akilo.com/main-2_000XXX.html redirected to http://www.akilo.com

Thank you for your advice. Best regards, Frank, akilo55

Apr 17th, 2009, 12:48 AM
Sounds like a job for mod_rewrite.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule main-1 http://www.babysafari.us [L]
RewriteRule main-2 http://www.akilo.com [L]
in your .htaccess, if you want all URLs containing "main-1" or "main-2" redirected to the specified sites.

Apr 17th, 2009, 05:53 PM
Or RedirectMatch (http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch)

RedirectMatch 301 ^/main-1_000[0-9]+\.html$ http://www.babysafari.us/
RedirectMatch 301 ^/main-2_000[0-9]+\.html$ http://www.akilo.com/

To send a 301 (permanent) redirect and only match /main-1_000XXX.html and /main-2_000XXX.html with mod_rewrite

Options +FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^main-1_000[0-9]+\.html$ http://www.babysafari.us/ [R=301,L]
RewriteRule ^main-2_000[0-9]+\.html$ http://www.akilo.com/ [R=301,L]