Forum Moderators: phranque

Message Too Old, No Replies

Rewriting to leave a URL pattern alone?

Rewrite, conflicting with ScriptAlias

         

craig1972

5:30 am on Sep 19, 2007 (gmt 0)

10+ Year Member



Hi

I have a website which uses rewrite for the main root path. E.g.,

http://example.com/xyz/
http://example.com/abc/

These are all rewritten. And this is working.

However, as with many cpanel installs, I have mailman working (the mailing list thing). The URL for this is usually:

http://example.com/mailman/admin/....

This above mailman bit is accomplished by the following line in httpd.conf as usual:

ScriptAlias /mailman/ /usr/local/cpanel/3rdparty/mailman/cgi-bin/

Given that I do want "example.com/mailman" to be left alone, I have the following internal rewrite rule in my httpd.conf VirtualHost directive for mysite:

RewriteRule ^/mailman/(.*)$ /mailman/$1 [L]

But this is not working. Shouldn't this code leave the "mailman" URL pattern alone? This is giving me a 404, because I of course do not have a subfolder in my public_html called "mailman".

So how can I make the ScriptAlias and the url rewrites play along together?

Thanks!

[edited by: jdMorgan at 12:49 pm (utc) on Sep. 19, 2007]
[edit reason] example.com [/edit]

g1smd

11:44 am on Sep 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Put a NOT condition in front of the other rule, so that it isn't called for that one condition.

Not is done with a "!".

craig1972

12:17 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



Thanks for replying. But I am not sure I understand. Where should the! go -- in the "mailman" setting in my example? How would it look?

Edit: I found this thread after some searching: [webmasterworld.com...]

Based on this example, I'm trying the following rule:

[quote]RewriteRule!^(mailman) - [F]
[/quote]

But this started giving me 403 for all my conditions! The example uses the "RewriteCond" stuff, which I don't have. I have simple "RewriteRules". Is this why?

Would appreciate any pointers, thanks! What could this code be, and where should I put it? My rules currently look like this...

RewriteRule ^/abc$ /mysite/i.php?u=abc [L]
RewriteRule ^/123$ /mysite/n.php?u=123 [L]
...

craig1972

12:42 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



I figured it out. Thanks!

RewriteCond %{REQUEST_URI}!^/mailman/
RewriteRule ....

I don't need the "F" or anything. Thanks!

jdMorgan

12:47 pm on Sep 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Before we go off copying inappropriate code snippets, modifying code, and writing new code, let's nail down the problem a bit better.

What is the difference between mailman URLs you do want to rewrite or Alias to cgi-bin, and those that you don't want modified?

If the difference is that the ones you want sent to the cgi-bin directory all start /mailman/admin, and those that you don't want diverted are /mailman/<anything else or nothing>, then the problem lies with the ScriptAlias directive alone, and no other code is needed. Just use


ScriptAlias /mailman/admin /usr/local/cpanel/3rdparty/mailman/cgi-bin/admin

If your needs are more complex, then you'll have to deal with another problem, in that these directives are processed by module order, and not by the order that the directives appear in your .htaccess and config files. For that reason, it may be necessary to replace the mod_alias directive with a mod_rewrite directive to allow you to control execution order, and thereby, to control precedence.

Jim

g1smd

11:24 pm on Sep 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As ever I'm looking at a single tree and jd has already surveyed the whole forest. :-)

:-)