Web Analytics Made Easy -
StatCounter Newbie -- htaccess question - CodingForum

Announcement

Collapse
No announcement yet.

Newbie -- htaccess question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie -- htaccess question

    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

    and

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

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

  • #2
    Sounds like a job for mod_rewrite.
    Put
    Code:
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteRule  main-1 http://www.babysafari.us [L]
      RewriteRule  main-2 http://www.akilo.com [L]
    </IfModule>
    in your .htaccess, if you want all URLs containing "main-1" or "main-2" redirected to the specified sites.
    .My new Javascript tutorial site: http://reallifejs.com/
    .Latest article: Calculators — Tiny jQuery calculator, Full-fledged OOP calculator, Big number calculator
    .Latest quick-bit: Including jQuery — Environment-aware minification and CDNs with local fallback

    Comment


    • #3
      Or RedirectMatch
      Code:
      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
      Code:
      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]
      </IfModule>

      Comment

      Working...
      X