301 Redirect redirects dynamic links to homepage, not to subpage

Discussion in 'Apache' started by CaptainCarrot, Jan 23, 2010.

  1. #1
    I moved from static pages to a CMS (Textpattern), so I set up a mod_rewrite rule to redirect my dynamic links to the new ones. It's working, sort of. All links redirect, but not to the appropriate subpages. Instead, they all land at the homepage. The original link structure was in the format of http://www.ajw-art.com/index.php?page=illustration

    Here's what I have in my .htaccess file. This is the first time I've tried to do this, so any help would be appreciated:

    #DirectoryIndex index.php index.html

    #Options +FollowSymLinks
    #Options -Indexes

    <IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /relative/web/path/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]

    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(.*) index.php

    RewriteCond %{HTTP:Authorization} !^$
    RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]

    RewriteCond %{QUERY_STRING} ^page=illustration$
    RewriteRule ^/index.php$ http://www.ajw-art.com/portfolio/? [R=301,L]

    RewriteCond %{QUERY_STRING} ^page=resume$
    RewriteRule ^/index.php$ http://www.ajw-art.com/resume/? [R=301,L]

    RewriteCond %{QUERY_STRING} ^page=contact$
    RewriteRule ^/index.php$ http://www.ajw-art.com/contact/? [R=301,L]

    </IfModule>

    #php_value register_globals 0
     
    CaptainCarrot, Jan 23, 2010 IP
  2. aandamar

    aandamar Well-Known Member

    Messages:
    243
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    Digital Goods:
    3
    #2
    You can do simplier on wordpress by adding some text bellow on 404.php from edit html..


    <?php
    header("Status: 301 Moved Permanently");
    header("Location:http://www.yoursite.com/");
    ?>

    don't forget to change the yoursite.com text..
     
    aandamar, Jan 23, 2010 IP
  3. CaptainCarrot

    CaptainCarrot Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    @aandamar But since all pages use the same 404, wouldn't that still direct traffic back to the homepage? From what I gathered while researching the issue, I thought I had to use an .htaccess solution because I was dealing with individual dynamic pages that I want remapped to the appropriate subpages.
     
    CaptainCarrot, Jan 23, 2010 IP
  4. aandamar

    aandamar Well-Known Member

    Messages:
    243
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    Digital Goods:
    3
    #4
    method that I posted is for the noobs,
    they can easily redirect the loss page to homepage without opened the cpanel..
    editing .htaccess still better than anything that I do..
    regards
     
    aandamar, Jan 23, 2010 IP