httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krist van Besien <krist.vanbes...@gmail.com>
Subject Re: [users@httpd] htaccess serving different domain with different front controllers
Date Thu, 24 Sep 2009 11:06:40 GMT
On Thu, Sep 24, 2009 at 8:43 AM, james cauwelier
<james.cauwelier@gmail.com> wrote:

> Here is my .htaccess (I deleted unimportant parts from my colleague),
> I suspect the line with [S=1] is to blame:

Yes, it is. [S=1] is only valid for a RewriteRule, not a RewriteCond.


> # redirect only when file not found
> RewriteCond %{REQUEST_FILENAME} !-f
>
> RewriteCond %{HTTP_HOST}  ^sioen.* [S=1]
>
> RewriteRule ^(.*)$ /web/index.php?command=$1 [QSA,L]
> RewriteRule ^(.*)$ /web/sioen.php?command=$1 [QSA,L]

I think you better study the order in which Rewriterules and
RewriteCond's get processed.
Have a look here:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_tech.html#InternalRuleset

Basically your request will first be checked against the first
RewriteRule. Since your first RewriteRule rule matches anything it
will trigger, and then the RewriteConds above it are checked. If all
mathches the rule is applied. Since you have the L flag no other rules
are applied after one matches.
The S flag is meant to skip the next RewriteRule, in case a rule
matches. It is only needed if you have some other rules that need to
be applied.

So corrected for syntax your rules look like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST}  ^sioen.*
RewriteRule ^(.*)$ /web/index.php?command=$1 [QSA,L]

RewriteRule ^(.*)$ /web/sioen.php?command=$1 [QSA,L]

I usually don't put any whitespace between RewriteCond and RewriteRuld
statements, so there is no doubt as to what belongs together.

The above might however not do what you want it to do (judging by your
previous attempt). Most probably you want this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /web/index.php?command=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST}  ^sioen.*
RewriteRule ^(.*)$ /web/sioen.php?command=$1 [QSA,L]

HTH,

Krist
(Tussen haakjes, is "sioen" wat ik denk dat het is :-)

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message