Getting mod_write rules in the Server Config context to apply to all sites
Long time reader, first time poster.
I've got some rewrite rules that work fine within a virtualhost context, but I can't get it to apply at the server config context, which I want to do so it applies to ALL virtual hosts.
The directives:
<IfModule mod_rewrite.c>
RewriteEngine On
Rewr开发者_如何学运维iteRule ^/?cgi-sys/defaultwebpage\.cgi$ / [R=301,L]
</IfModule>
I've tried altering it to not enforce the start and end as such:
RewriteRule cgi-sys/defaultwebpage\.cgi / [R=301,L]
But I can't trigger it.
What am I missing?
Apache/2.2.13
As asked in the comments, the user is entering:
http://www.example.com/cgi-sys/defaultwebpage.cgi
The following log entry results:
203.4.5.6 - - [05/Apr/2011:10:23:16 +1000] "GET /cgi-sys/defaultwebpage.cgi HTTP/1.1" 200 26 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko)
Version/5.0.4 Safari/533.20.27"
Now, the site in question has an .htaccess file with this rule that I believe is intercepting this request:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
I temporarily disabled that directive, and then apache just served a vanilla 404:
203.45.73.63 - - [05/Apr/2011:10:27:28 +1000] "GET /cgi-sys/defaultwebpage.cgi HTTP/1.1" 404 - "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko)
Version/5.0.4 Safari/533.20.27"
For what I understand of your rules:
client writes example.com/cgi-sys/defaultwebpage.cgi
the rule match and redirect on /
that will direct to index.php
by rewritting of the last rule.
Does the file example.com/index.php
exists?
Of course, you've reloaded the server config files after doing this? You don't have to in per-directory rules but you do here.
精彩评论