mod_rewrite:将action.something.com更改为www.something.com/script.php

I would like to call a script within a site, co it looks like it is a separte website. So if the script name is

www.something.com/script.php

I would like to access it by:

action.something.com

by setting up .htaccess.

Right now, my .htaccess has this line:

RewriteRule ^(.*)$ index.php [QSA,L]

but this one:

RewriteRule ^(action.*)$ script.php [QSA,L]

does not work.

Any ideas?

Thanks!

The host part is not handled by RewriteRules. You need to use RewriteCond for that

RewriteCond %{HTTP_HOST} ^action.something.com$
RewriteRule ^(.*)$ script.php [QSA,L]

You can do that:

RewriteCond %{HTTP_HOST} ^action.something.com$
RewriteRule ^ http://www.something.com/script.php [QSA,R=302,L]

Change [R=302] for [R=301] when test work well.