Help making urls pretty with ht access

  • I’m looking to set htaccesss so that the following url


    /any-section?page=sub-section


    Looks like the following


    /any-section/sub-section


    Both '/any-section' and '/sub-section' could be anything.


    There is already the standard Perch htaccess (below) removing the .php from the end of the /any-section.php filename.


    Code
    1. # Redirect to PHP if it exists.# e.g. example.com/foo will display the contents of example.com/foo.phpRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME}.php -f
    2. RewriteRule ^(.+)$ $1.php [L,QSA]
  • This code works for me:


    I think it will only work to the second level but it works OK at the moment.

  • drewm

    Approved the thread.