How to write RewriteRule in .htaccess file?
# February 23, 2013 at 2:33 pm
Hi, I have created a cms on my localhost for a website. And I have created only one page where I am dynamically creating all other pages by passing different ids. So my pages are like this.
http://localhost/spscollege/allpages.php?id=1 for about-us
http://localhost/spscollege/allpages.php?id=2 for facilites
http://localhost/spscollege/allpages.php?id=3 for addmission
and so on…
I want to rewrite the rule for the url in .htaccess , and I googled it a lot but nothing seems to work. Let me tell you what all things I did so you can figure out what mistake i m making.
1- I created a .htaccess file and kept in the root directory of my folder(along with allpages.php)
2. I wrote (from a turtorial) this in the .htaccess file
RewriteRule ^home.*$ http://localhost/spscollege/allpages.php?id=1/ [R=301,L]
I also checked the configration in phpinfo() and I can see that mod_rewrite
I also used http://www.generateit.net/mod-rewrite/ to rewite which gave me this
RewriteRule ^([^/]*).html$ /spscollege/allpages.php?id=$1 [L]
but that didn’t work either
I watched a lot of youtube vidoes but nothing seems to be working for me.
What mistake m I making? and how do get this work . ):
I m using Xampp
I have never written the rewrite rule before, I would apperecite any help or suggestion.
You must be logged in to reply to this topic.