1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Cant redirect my URL with htaccess

Discussion in 'PHP' started by aleale, Feb 26, 2014.

  1. #1
    I am using WAMP and my url is localhost/hotel/hotels.php?id=21
    Using rewrite rule as follow,

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule hotels/id/(.*)/ hotels.php?id=$1
    RewriteRule hotels/id/(.*) hotels.php?id=$1

    But nothing happens..

    My mod_rewrite is on and also changes done in httpd.conf file.

    Please give me a suggesstion to handle the issue?
     
    aleale, Feb 26, 2014 IP
  2. edual200

    edual200 Active Member

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    To me it seems like it should be done like this...
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule hotels/id/(.*)/ hotel/hotels.php?id=$1
    RewriteRule hotels/id/(.*) hotel/hotels.php?id=$1

    I mean where is the htaccess file located at?
    here? localhost/
    or here? localhost/hotel/
     
    edual200, Mar 5, 2014 IP
  3. edual200

    edual200 Active Member

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    actually though im no pro in htaccess, looking at my htaccess your missing 2 things, $ and ^
    mine would look like this
    RewriteRule ^hotels/id/(.*)/$ hotel/hotels.php?id=$1 [QSA,L]
     
    edual200, Mar 5, 2014 IP
  4. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Please try the below code....

    
    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /hotels/
    RewriteRule ^id/([0-9a-zA-Z-]+)$ hotels.php?id=$1 [L]
    
    Code (markup):
    Also please check your server has mod_rewrite enable or not.....
     
    salmanshafiq, Mar 13, 2014 IP