Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Basic PHP / htaccess URL Rewrite?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #148831
    Presto
    Participant

    Hello guys,

    Not sure if this is easy or not, but I want to rewrite my php file URLs, not sure if this is done completely in the htaccess file or in php or both.

    Current URL:
    http://www.MYDOMAIN.com/index.php?page=home

    How do I get it to turn into the following automatically, if possible?
    http://www.MYDOMAIN.com/home.html

    #148833
    Presto
    Participant

    So I ended up creating a .htaccess file and adding the following to it. RewriteEngine On RewriteBase / RewriteRule ^([a-z]+).html$ index.php?page=$1 [L] Then to get it to work you just type in the URL i.e. /home.html and it works.

    *** UPDATE: Never mind, that did not work after all, sigh

    #148835
    Presto
    Participant

    Ok so the above works, but if there is a dash in the file name (i.e. contact-us.html) it fails, anyone know how to fix that?

    *** UPDATE:
    Found the fix: added - to ^([a-z0-9-]+)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.