views:

39

answers:

2

basically need to convert

with www or not, example.com/[anycharacter]

into

with www or not, example.com/cgi-bin/new-disk.cgi/dir/smooth/[anycharacter]

additinoally...

i would like to redirect ALL www.example.com into example.com

A: 

For part of your answer, I believe you can use this as an example to base off.. hopefully you use a test domain:

RewriteCond %{HTTP_HOST}   ^www\.example\.com [NC]
RewriteRule ^/(.*)         http://example.com/$1 [L,R=301]

Might need to add a (.*) and make it optional for the other part.

meder
+1  A: 

This should work for you:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !cgi-bin/new-disk.cgi/dir/smooth
RewriteRule ^(.*)$ /cgi-bin/new-disk.cgi/dir/smooth/$1 [L]

For the first two lines, it checks to see if you have www in your URL. If so, bounce it to the non-www version.

Note the exclamation mark (!) on the second last line. This is a not operator and in this test, is checking to see if your currently requested file isn't your final rewriting file, in this case:

cgi-bin/new-disk.cgi/dir/smooth

If that's true, shunt it to the actual rewrite script you have as pointed out in the final line.

The character, $1, references the first capture group as marked by the first set of parentheses on the same line.

random