Web Hosting Talk







View Full Version : mod rewrite: static to dynamic


webligo
12-13-2004, 02:31 AM
Hi guys, yet another mod_rewrite question.

I would like:
http://www.domain.com/string1/string2/string3
to redirect to:
http://www.domain.com/string1/string2/?u=string3

I've already looked over http://httpd.apache.org/docs/misc/rewriteguide.html, but I'm terrible with regex and could use some extra help.

Thanks!

astellar
12-13-2004, 08:38 PM
you can try the following lines in your .htaccess file:

RewriteEngine on
RewriteRule ^(.*) /string1/string2/?u=$1 [NC,L]

webligo
12-14-2004, 01:09 AM
hey astellar, thanks for the code but it doesnt seem to be working, i'm getting an internal server error

tarsius
12-14-2004, 01:33 AM
how about creating an index.php inside http://www.domain.com/string1/string2/string3 and then index.php will contain:

<?php
header("Location: http://www.domain.com/string1/string2/?u=string3");
exit();
?>

:)

webligo
12-14-2004, 01:57 AM
hey tarsius, thanks for the help but thats not what i need. "string1" and "string2" wont ever change, but "string3" will be a variable. i'm sorry i wasn't clear in the first post

webligo
12-14-2004, 01:59 AM
basically, I just want the .htaccess file to add the "?u=" between /string2 and /string3, so it looks like this:

/string2/?u=string3