Really Simple .htaccess rewrite help

Discussion in 'Apache' started by Northie, Jul 2, 2008.

  1. #1
    I have recently changed my hosting provider and although my previous configuration still works to an extent - it's not perfect.

    I used to route all requests through a custom 404 page (written in PHP), and set the headers accordingly.

    My new host still understands all this, but only ever sends a 404 header, even when i try to send a 200 OK or 301.

    To solve the problems I want to re-write the request url from something like this

    http://my-domain.com/here-are/some-variables/

    to

    http://my-domain.com/?here-are/some-variables/

    [Note the addition of the "?" after the domain name]

    I have tried

    RewriteEngine On
    RewriteRule (.*)/ /?$1

    and

    RewriteEngine On
    RewriteRule (.*)/ /index.php?$1

    neither of which worked (500 errors all over the place)

    A nudge in the right direction would really help....

    Thanks in advance for any suggestions or solutions.......
     
    Northie, Jul 2, 2008 IP
  2. Northie

    Northie Peon

    Messages:
    80
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I've been given this snippet for translating

    http://domain.com/this/that/

    to

    http://domain.com/?this/that/


    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
    RewriteRule ^/(.*)$ /?$1 [L]
    Code (markup):
    I've yet to test it, but will post my findings here when i get the chance
     
    Northie, Jul 3, 2008 IP
  3. innoxed

    innoxed Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    the rule you are using is generating an infinite loop.

    try using the negation character (^)

    something similar to this :

    RewriteRule ^[^\?](.+)$ /?$1 [L]

    may not work however, I got this from the top of my mind
     
    innoxed, Jul 4, 2008 IP