Forum Moderators: phranque
RewriteCond %{HTTP_HOST} ^thedomain.com [NC]
RewriteRule ^(.*)$ http://wwwthedomain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^thedomain.com [NC]
RewriteRule ^(.*)$ http://www.thedomain.com/$1 [L,R=301]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1&%1 [L]
RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1 [L]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1&%1 [L]
RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1 [L]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1&%1 [L]
RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1 [L]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule tell_(.*).html index.php?act=taf&productId=$1&%1 [L]
RewriteRule tell_(.*).html index.php?act=taf&productId=$1 [L]
I want to redirect any non "www" to www.thedomain but I need the rest to work too!
If I remove the www.redirect it works fine.
Quick fix: Exclude POSTS from the redirect:
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
[added]
I think you'll find your serve runs faster if you use more-specific patterns, anchor those patterns, and escape "special regular-expressions-token" characters as required. Example:
RewriteRule ^tell_([^.]+)\.html$ index.php?act=taf&productId=$1 [L]
For more information, see the concise regex tutorial cited in our forum charter [webmasterworld.com].
[/added]
Jim
[edited by: jdMorgan at 8:19 pm (utc) on May 23, 2007]