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 suggestion to handle the issue?

Zeeshan
  • 1,659
  • 13
  • 17
  • What is supposed to happen with `hotels.php?id=21`? I mean, something should happen with `hotels/id/21`, but it won't change a thing for `hotels.php?id=21`! – evuez Feb 26 '14 at 09:57
  • yes.. i want it to change to hotels/id/21 but nothing changed. the url remains same even after doing everything. – user3355237 Feb 26 '14 at 10:00
  • Well you have to go to `localhost/hotel/hotels/id/21`, a rewrite rule isn't a redirection! – evuez Feb 26 '14 at 10:02
  • ohh thank you.. How to make redirection then. can you please help me on this? – user3355237 Feb 26 '14 at 10:07
  • You should check out the [Apache documentation](http://httpd.apache.org/docs/current/rewrite/remapping.html) about redirections – evuez Feb 26 '14 at 10:13
  • can you please giv me a solution here?? i will be thankful for you – user3355237 Feb 26 '14 at 10:23

1 Answers1

1

You must use flags for your RewriteRule. You can change it as follow

RewriteEngine on
RewriteRule  ^hotels/id/([\d]+)/?$ hotels.php?id=$1 [NC,L]

You can call your pages from

localhost/hotel/hotels/id/12

If your .htaccess file is located in localhost/hotel .

Huseyin
  • 1,499
  • 2
  • 25
  • 39
  • how to redirect the original page to the rewritten page.. ? – user3355237 Feb 26 '14 at 11:15
  • If http://localhost/hotel/hotels.php?id=21 works, you can use http://localhost/hotel/hotels/id/21 . If your .htaccess file is located on hotel folder. Please check .htaccess working with http://stackoverflow.com/questions/4321990/htaccess-not-working-on-wamp – Huseyin Feb 26 '14 at 11:27