Mod Rewrite Quick Question

Discussion in 'Apache' started by crivion, Feb 5, 2013.

  1. #1
    I have the following

    RewriteEngine On
    RewriteBase /



    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^view-image/(.*)$ index.php?page=view-image&image=$1 [L]
    RewriteRule ^(.*)$ index.php?page=$1 [L]


    What I am trying to achieve here is to rewrite anything like
    index.php?page=page to /page
    index.php?page=second to /second

    That part works

    But when I try to rewrite index.php?page=view-image&image=image_title to /view-image/imag_name it doesn't work

    Any suggestions?
     
    crivion, Feb 5, 2013 IP
  2. cesurasean

    cesurasean Active Member

    Messages:
    269
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Cannot use / inside a url string.
     
    cesurasean, Feb 19, 2013 IP
  3. eldiablo

    eldiablo Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    80
    #3
    If you want to rewrite for example:

    yourdomain.com/index.php?text
    to
    yourdomain.com/text/

    you should use this:

    RewriteEngine On
    RewriteRule ^([^/]*)/$ /index.php?page=$1 [L]

    It should work. :)

    EDIT: I've just seen that you have same thing (sorry I'm a bit tired), I'm going to check on other part and edit my post ASAP.

    And this should work for other part:


     
    eldiablo, Feb 19, 2013 IP
  4. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #4
    Nevermind i've solved it myself in minutes after posting.
     
    crivion, Feb 20, 2013 IP