WordPress.org

Ready to get started?Download WordPress

Forums

301 Redirects not working!! (6 posts)

  1. XMIRS
    Member
    Posted 2 years ago #

    Hi,

    I have built a new wordpress site to replace my old one, and am having trouble trying to set up redirects. I have tried plugins, through cpanel as well as direct in htaccess and have no idea where i am going wrong.

    I have spoken to my hosting provider and basically they were no help and said it was something to do with wordpress.

    An example of what i want is.....

    airconspecialists.co.nz/index.php?p=1_2_Products to be redirected to http://airconspecialists.co.nz/wp/heat-pumps/

    By using the redirects in cpanel i get this code.....

    # -FrontPage-
    
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    
    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName airconspecialists.co.nz
    AuthUserFile /home/aircons2/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/aircons2/public_html/_vti_pvt/service.grp
    
    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    RewriteCond %{HTTP_HOST} ^airconspecialists\.co\.nz$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.airconspecialists\.co\.nz$
    RewriteRule ^index\.php$ "http\:\/\/airconspecialists\.co\.nz\/wp\/heat\-pumps\/" [R=301,L]

    I have tried moving the inserted redirect code to different places to see if it changes. It seems if i move it above the #BEGIN wordpress it kinda works however it redirects to http://airconspecialists.co.nz/wp/heat-pumps/?p=1_2_Products which of course just brings up a 404.

    If any one can help it would be much appreciated as this is really starting to do my head in now.

    Cheers,

    Adam.

  2. adpawl
    Member
    Posted 2 years ago #

    put 301 before wp rules

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    ...301...
    </IfModule>
    
    # BEGIN WordPress
    ...
  3. Phil
    Member
    Posted 2 years ago #

    Ideally, you want the 301 redirect instruction immediately after the rewrite engine line:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^airconspecialists\.co\.nz$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.airconspecialists\.co\.nz$
    RewriteRule ^index\.php$ "http\:\/\/airconspecialists\.co\.nz\/wp\/heat\-pumps\/" [R=301,L]
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    # -FrontPage-
    
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    
    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName airconspecialists.co.nz
    AuthUserFile /home/aircons2/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/aircons2/public_html/_vti_pvt/service.grp
  4. adpawl
    Member
    Posted 2 years ago #

    Phil, not so ideally - sometimes section BEGIN/END WordPress is overwritten. ;)

  5. Phil
    Member
    Posted 2 years ago #

    If using plugins that overwrite the htaccess, then yes.

    I have it set like this on 3 sites and they all do the job (although there is nothing to overwrite htaccess). If you have plugins that do overwrite the htaccess, then yes, keep it out of the wordpress section. :)

  6. XMIRS
    Member
    Posted 2 years ago #

    Done as adpaul has suggested remains the same with no redirect. Done as phil has shown does redirect however redirects to the wrong url and brings up a 404 it redirects me to...

    http://airconspecialists.co.nz/wp/heat-pumps/?p=1_2_Products

    So it is combining both new and old urls.

    Any other suggestions are welcome as my SEO guy has stressed to me to set up the redirects before i set the new wordpress site live.

    Cheers,

    Adam.

Topic Closed

This topic has been closed to new replies.

About this Topic