Htaccess help

I have a URL that I would like to make it to look nicer
like http://www.your-site.cm/action/name-of-movie

http://www.your-site.cm/movie.php?cat=$1&movie=$2

anyone

thanks

Kyle R,

Thanks for the effort but that’s BAD advice (IMHO).

sinz,

[rant #1][indent]The use of “lazy regex,” specifically the :kaioken: EVERYTHING :kaioken: atom, (.*), and its close relatives, is the NUMBER ONE coding error of newbies BECAUSE it is “greedy.” Unless you provide an “exit” from your redirection, you will ALWAYS end up in a loop![/indent][/rant #1]

My advice is to learn a little regex rather than use “lazy regex” which gets noobies in more trouble than they can handle (looping is the primary example but (.)/(.) will sent even ‘directory/’ to movie.php and that’s NOT what you need (especially if you have css, js, image files in subdirectories.

If you need a place to start learning about the simplified regex used by mod_rewrite, please start with the tutorial linked in my signature.

Regards,

DK


RewriteEngine On
RewriteRule ^(.*)/(.*)$ /movie.php?cat=$1&movie=$2

That should do it.

But be careful because if someone goes to http://www.site.com/contact/blah it will class contact as a category and blah as a movie…

You’d be better off having for example: http://www.site.com/categories/action
http://www.site.com/movies/name-of-movie