Grow your CSS skills. Land your dream job.

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

    Options +FollowSymLinks
    RewriteEngine On
    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
    is on.
    I also used http://www.generateit.net/mod-rewrite/ to rewite which gave me this

    RewriteEngine On
    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.
    Thanks

    # February 23, 2013 at 9:18 pm

    What happens when you try to use the rewrite rule? Does it 404?

    # February 23, 2013 at 10:14 pm

    It doesn’t show any errror.
    But when I replaced a letter ‘m’ from the word +FollowSymLinks to +FollowSynLinks(just to check weather its even doing something or not.) , it showed error 500, thats the only error I have seen, else it doesn’t show any error.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".