Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Posts
    293
    Thanks
    63
    Thanked 8 Times in 8 Posts

    mod_rewrite advice please!

    My website uses a CMS which loads page content according to the value of a GET var called "page".

    E.g. http://www.mysite.com/index.php?page=mypage will load the content for mypage.

    How can I generically mod_rewrite http://www.mysite.com/index.php?page=xxx as http://www.mysite.com/xxx ?

  • #2
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    Try something like this (untested):

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?page=$1 [L]
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Posts
    293
    Thanks
    63
    Thanked 8 Times in 8 Posts
    Many thanks for that.

    Reading through, I realise I have no idea how it works! Seems I need to familiarise myself with mod_rewrite. Can you recommend a good online tutorial that explains the syntax?

  • #4
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    I've always found...

    http://net.tutsplus.com/tutorials/ot...te-for-apache/

    ... to be quite a good all round tutorial on mod_rewrite. Combine it with a bit of Regular Expression knowledge and you should be golden.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •