6 replies
  • WEB DESIGN
  • |
Have rebuilt a website that previously had .php extensions, the new site uses wordpress and the page names are for example domain.com/newpage/ the domain name has been retained.

Is it possible to redirect a visitor who tries to access say domain.com/contact.php to domain.com/contact-us/

Have tried a few routes using the htaccess file but can't seem to get it to work.

cheers

Tony
#redirects
  • Profile picture of the author angelamh
    Did you try stripping all of the code from the old php page (including any html) and inserting

    <?php
    header( 'Location: [insert new url here]' ) ;
    ?>

    You have to do it with a completely blank page... let me know if it works!
    {{ DiscussionBoard.errors[703915].message }}
  • Profile picture of the author tonyscott
    Hi, thanks for that, might come in useful sometime, but for now, the old pages no longer exist.

    Tony
    {{ DiscussionBoard.errors[703935].message }}
  • Profile picture of the author angelamh
    Well, you could create a new old page at domain.com/contact.php for the redirect (that's how I tested my response), or did I miss something?
    {{ DiscussionBoard.errors[703947].message }}
  • Profile picture of the author RedMatrix
    You can edit your .htaccess file. Put this line in there:

    Code:
    Redirect /contact.php http://domain.com/contact-us/
    Signature

    ~Dave

    {{ DiscussionBoard.errors[706443].message }}
    • Profile picture of the author tonyscott
      Originally Posted by RedMatrix View Post

      You can edit your .htaccess file. Put this line in there:

      Code:
      Redirect /contact.php http://domain.com/contact-us/
      Many thanks RedMatrix - that worked

      Tony
      {{ DiscussionBoard.errors[714819].message }}
  • Profile picture of the author wayfarer
    I recommend you use a 301 response code in addition to the redirect. In .htaccess the above would look like:
    Code:
    Redirect 301 /contact.php http://domain.com/contact-us/
    This tells search spiders and other non-human user agents that the redirect is to the page's new permanent location.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[715158].message }}

Trending Topics