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 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2010
    Location
    In a dump
    Posts
    64
    Thanks
    9
    Thanked 2 Times in 2 Posts

    Rewrite not picking up variable

    Hi I have the following re_write condition:

    Code:
    RewriteRule ^([^/\.]+)\.php$ index.php?page=$1 [L]
    Which when I try to access the page like www.domain.com/newsite/hello.php
    the only thing stored in the $_GET is "index".

    Can someone explain to me what I have managed to do wrong? I know it is slightly working because when I change it to:

    Code:
    RewriteRule ^([^/\.]+)\.php$ index.php?page=bob [L]
    it supplies the $_GET with the string "bob".

    Thanks.

  • #2
    120
    120 is offline
    Regular Coder
    Join Date
    Nov 2009
    Location
    UK
    Posts
    105
    Thanks
    6
    Thanked 15 Times in 15 Posts
    At at guess, when it iterates the second time round you'll match the index.php in the redirect.

    Untested - but try this:
    Code:
    RewriteRule ([^/\.]+)([^index])\.php$ index.php?page=$1 [L]
    There is always plenty of idol work for the devils hands to do
    Registered Linux User 475075 : Project Honeypot

  • #3
    New Coder
    Join Date
    Jan 2010
    Location
    In a dump
    Posts
    64
    Thanks
    9
    Thanked 2 Times in 2 Posts
    Thanks for the reply. It did not work instantly but I have managed to work it.

    Code:
    Code:
    RewriteRule ^([^index])([^/\.]+)\.php$ index.php?page=$1$2 [L]
    This code works if anyone else requires it. I dont understand why it works though. If anyone can explain it that would be aces.

    Note: the $1$2 at the end is required as only part of the variable is put in each.


  •  

    Posting Permissions

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