Jump to content

Cant redirect my URL with htaccess


RahulVicky001

Recommended Posts

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?     

Link to comment
Share on other sites

This is not how mod_rewrite works. It does not automatically change the urls for you. You need to change your existing urls to the new url format that matches the rewriteRule you setup in the .htaccess. eg change your links to

echo '<a href="/hotels/id/'.$hotel_id.'>View Hotel</a>';

When you click the link you'll go to locahost/hotels/id/21. Here mod_rewrite will match that url with the rewriterule in the htaccess. It'll now pass the number 21 to hotels.php?id=21.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.