WordPress.org

Ready to get started?Download WordPress

Forums

Redirect all pages from .php to no extension (2 posts)

  1. beyonddesigning
    Member
    Posted 3 years ago #

    Hi,

    Not sure if this is a wordpress setting or more of a .htaccess setting but here goes:

    I've rebuilt a static site on wordpress and there is a change in the URLs now.
    Before the urls were like this: sitename.com/page-name.php
    Now in wordpress its like this: sitename.com/page-name/

    So the URLs are exactly the same apart from the removed .php extension.

    How can I create an .htaccess code that will redirect any .php link into a non .php extension?
    Since I don't have any page on the site now which has an extension I think it would make more sense to use a dynamic code rather than make a 301 redirect for each and every page.

    So if someone opens my site with a link like sitename.com/page-name.php the .htaccess automatically takes him to sitename.com/page-name/

    Any help would be appreciated!

    Thanks!

  2. Sure

    RedirectMatch 301 (.*)\.php$ http://www.example.com$1/

    This is pretty basic htaccess stuff :) You should read http://www.webweaver.nu/html-tips/web-redirection.shtml

Topic Closed

This topic has been closed to new replies.

About this Topic