views:

93

answers:

3

In order to convert dynamic URLs on my site www.kitesmovie.co.in to static urls. Eg: www.kitesmovie.co.in/stories.php?id=10 to www.kitesmovie.co.in/Barbara_Mori_Hrithik_Roshan_New_Movie.

I tried using rewriting rules in my htaccess files, but it did not work. Please tell me how to do this.

Thanks a lot in advance.

A: 

Lots of missing info there. If you are using apache with mod_rewite installed, place this in your .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule stories.php?id=10 Barbara_Mori_Hrithik_Roshan_New_Movie [R,L]

</IfModule>
Mike
A: 

You might want to have a look at this article: http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/

Generally, you would use a RewriteRule something like this:

RewriteRule ^stories.php?id=10$  Barbara_Mori_Hrithik_Roshan_New_Movie [R=301,L]

If that's not working for you, then feel free to add more details to your question.

zombat
+1  A: 

It's not really clear what you are trying to achieve. When you say "convert dynamic urls to static urls", do you really want to have user to type in the ...?id=10 and the file named Barbara_Mori_Hrithik_Roshan_New_Movie lives on your server? I think, it's the opposite way - you want to let the user type in the long & nice title and actually resolve it to ?id=10 If this is the case, the @Mike's answer is nearly correct, you only have to swap the parts of the last line:

RewriteRule Barbara_Mori_Hrithik_Roshan_New_Movie stories.php?id=10 [R,L]

Another question - are you sure you have the .htaccess working? An easy way to check is to set the contents of .htaccess to

order deny, allow
deny from all

And see if you can still access that directory. If you can, this means the "deny from all" does not work. Then check your apache config - is .htaccess allowed in the particular virtualhost and/or directory.

naivists