Hey, well on my website I'm currently using this url structure to display the movies. /video.php?id=(videoid) I'm looking to change this using mod_rewrite so that it displays as /(movie name).html I have no clue how to do this. Could anyone help me out?
you will need to update your video.php file to accept movie names instead of IDs, and then you just need to use mod_rewrite: RewriteEngine On RewriteCond {REQUEST_URI} !index.html$ [NC] RewriteCond {REQUEST_URI} \.html$ [NC] RewriteRule (.*).html /video.php?name=$1 [L,R=302] Code (markup): this is from the top of my head, so it may need a little tweaking.. the first condition excludes the index.html file (not case sensitive), the second condition targets all the urls ending with .html and the rule is to take the filename without the html and do a 302 redirect (can also be 301) to the correct form you'll wanna use.
thanks Exactly what I was looking for. Do I have to remove the id's ? Or could i just add in the title?
Well you could use MovieName-id.html like Finding-nemo-54.html where 54 is the movie id and then use RewriteRule -(\d+).html$ video.php?id=$1 [L] Code (markup): That should do it
in that case you just need RewriteEngine On RewriteBase / RewriteRule ^video/(\d+)/(.*?)\.html$ /video.php?id=$1 [L] Code (markup): I am assuming that your id is a number and not letters as well