Mod_Rewrite Problem?

Discussion in 'Site & Server Administration' started by Flor1anHoxha, Jul 28, 2013.

  1. #1


    Hi guys,
    Here is my current url: ?p=new-homes-by-place&id=416&name=east-homes
    Here is how I want to have my url: ?p=new-homes-by-east-homes&id=416

    So far, I have generated this way using .htaccess:


    Code:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^p=new-homes-by-([^/]+)&id=([0-9]+)?$ ?p=new-homes-by-place&id=$2&name=$1 [L]​
    This actually works somehow. However, I miss the question mark on front of the new url (?p=new...). I know that this has to do with query string, but I dont know how to implement so I can keep the question mark on front.
    A help on this will be highly appreciated.
     
    Flor1anHoxha, Jul 28, 2013 IP
  2. profi7

    profi7 Active Member

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #2
    Try using the following rules:
    RewriteCond %{QUERY_STRING} ^(.*)\&name=east-homes
    RewriteRule .* http://domain.com/?$1%1%2 [R=301,L]
    Code (markup):
    or, something like this:

    RewriteCond %{QUERY_STRING} \&name=east-homes
    RewriteRule .* http://domain.com/? [R=301,L]
    Code (markup):
     
    profi7, Jul 28, 2013 IP
  3. Flor1anHoxha

    Flor1anHoxha Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    I tried using those, but it doesn't work. Any idea?
     
    Flor1anHoxha, Jul 28, 2013 IP