Web Hosting Talk







View Full Version : URL Rewrite


beachcompcom
03-08-2010, 04:34 PM
Hi folks,

I'm new to IIS7/Url rewrites.
Im trying to make
videos/playvideo.php?video=AjLlW8Uk8B0&feature=youtube_gdata&name=Eclipse%20Trailer
Into
videos/video-AjLlW8Uk8B0&feature=youtube_gdata-Eclipse_Trailer.html.
My rule is:
RewriteEngine on
Options +FollowSymlinks
RewriteRule ^video-(.*)-(.*) playvideo.php?video=$1&name=$2

But it simply will not work in IIS.

Could anyone please point me in the right direction or tell me what I have wrong?

I've been RTFM on IIS and no luck.

Thanks!

Mark G
03-10-2010, 08:56 AM
writing regular expressions can be tricky. You might post the question on the mod_rewrite discussion board (http://forum.modrewrite.com/) or consult the mod_rewrite cheat sheet (http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/). Good luck!

mattle
03-10-2010, 12:32 PM
Hi folks,

videos/playvideo.php?video=AjLlW8Uk8B0&feature=youtube_gdata&name=Eclipse%20Trailer

Into

videos/video-AjLlW8Uk8B0&feature=youtube_gdata-Eclipse_Trailer.html.

RewriteRule ^video-(.*)-(.*) playvideo.php?video=$1&name=$2



You're backwards :) The regex will match the uri and the last bit is where you are sending someone:


RewriteRule ^video/playvideo.php?video=(.*)&name=(.*) videos/video-$1-$2.html

Driver01
03-10-2010, 12:51 PM
You're backwards :) The regex will match the uri and the last bit is where you are sending someone:


RewriteRule ^video/playvideo.php?video=(.*)&name=(.*) videos/video-$1-$2.html

hmm...not sure about IIS7 but with apache I normally do:


RewriteRule ^video-(.*)-(.*)\.html$ playvideo.php?video=$1&feature=youtube_gdata&name=$2

use this link in the document:


video-AjLlW8Uk8B0-Eclipse%20Trailer.html

Chris Stinson
03-10-2010, 08:53 PM
hmm...not sure about IIS7 but with apache I normally do:


RewriteRule ^video-(.*)-(.*)\.html$ playvideo.php?video=$1&feature=youtube_gdata&name=$2



IIS 7 will import Apache rewrite rules with no issues.

Dr:linux
03-11-2010, 02:25 AM
You can use the new URL rewrite featured in IIS7. You will need to have the URL rewrite module installed.

You can get the module from these sites. Please take a look.

Download the x86 version for IIS 7.0 (http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1691)
Download the x64 version for IIS 7.0 (http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1692)

There are more articles relating to it and it clearly explains how to create rewrite rules.
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/

Hope this helps for you. :)