I need the RewriteRule for these www.site.com/foo must redirect to www.site.com/index.php?var1=foo and www.site.com/foo/bar must redirect to www.site.com/index.php?var1=foo&var2=bar Any help would be greatly appreciated. Thanks.
Hi, Try this (not tested) : RewriteEngine on RewriteRule ^([a-z]+)$ /index.php?var1=$1 [L] RewriteRule ^([a-z]+)\/([a-z]+)$ /index.php?var1=$1&var2=$2 [L] Code (markup): This assumes that foo and bar can only contain lower case letters. Jean-Luc
for lower and upper case. RewriteEngine on Options +SymLinksIfOwnerMatch RewriteBase / RewriteRule ^([aA-zZ]+)/(aA-zZ]+)$ index.php?var1=$1&var2=$2 [L] RewriteRule ^(aA-zZ]+)$ index.php?var1=$1 [L] Code (markup): If url will contain upper and lower case. If problem, server may require leading / RewriteEngine on Options +SymLinksIfOwnerMatch RewriteBase / RewriteRule ^/([aA-zZ]+)/(aA-zZ]+)$ index.php?var1=$1&var2=$2 [L] RewriteRule ^/(aA-zZ]+)$ index.php?var1=$1 [L] Code (markup):
both didn't work I can redirect www.site.com/foo[I].html[/I] to www.site.com/index.php?var1=foo but I can't redirect without that .html
Try to see if this works. RewriteEngine on Options +SymLinksIfOwnerMatch RewriteBase / RewriteRule ^(.*)/(.*)$ index.php?var1=$1&var2=$2 [L] RewriteRule ^(.*)$ index.php?var1=$1 [L] Code (markup):
@SpeedyDomainRegistration I had already tried that. But I have found the way to do this This has worked like a charm. I have found this via http://wettone.com/code/clean-urls and modified it a little. Thanks all anyway.
does anyone know a way to use mod_rewrite to replace spaces (%20) in the url and replace them with a dash (- or ~)? any help on this would be most appreciated...
Here it is: RewriteRule ^([[:alnum:]]+)[[:space:]]([[:alnum:]]+).([[:alpha:]]+)$ http://www.somedomain.com/$1-$2.$3 [NC,R=301,L] Code (markup): more at http://www.webmasterworld.com/forum92/317.htm Only work with 1 space in url
Make the script search for spaces and change them in to -. Then you don't need to make mod_rewrite do it. (You would need to know php to edit the script!)