How to rename the url of each page in the address bar?

Hello guys let me try to explain what I'm trying to do. My web site www.website.com has a few pages and it is hosted Apache via Aruba

www.website.com/site/index.php
               /site/page1.php
               /site/page2.php
               /site/page2.php?action=someaction=12345

My question for you is, can I rename them in a simple way like

www.website.com/site/index.php ---> www.website.com
               /site/page1.php ---> www.website.com/page1
               /site/page2.php ---> www.website.com/page2
               /site/page2.php?action=someaction=12345 ---> www.website.com/page2

I've read online about .htaccess but I have no clue how to set it up, can someone explain it to me? Thank you

1 answer

  • answered 2018-11-07 19:07 Mehran

    I think it`s like this:

      RewriteEngine On
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
    
        RewriteRule ^website.com/site/index ?$ website.com
        RewriteRule ^website.com/page([0-9]+)/ website.com/site/page=$1
        RewriteRule ^website.com/site/page([0-9]+) /?action=$1&%{QUERY_STRING} [L]