You are not logged in.

#1 2011-09-08 03:41:51

gnarliprime
Member
Registered: 2011-09-01
Posts: 11

modrewrite do not redirect certain IPs

I've tried this a number of ways in my vhosts file, but none of my changes work as expected. I have a redirect to https, but i don't want to redirect my ip or my work ip, reasons being, I can't access non trusted https addresses at work and m0n0wall doesn't allow me to connect from home on my ip (standard DNS goes through cloudflare). I also imagine the duplication of 443 and 80 virtual host entries are configured incorrectly although they are working. Here is the pertinent portion of my vhost


<VirtualHost *:443>
    ServerAdmin busted@example.com
    DocumentRoot "/srv/http/example
    ServerName example.com
    CustomLog "/srv/http/logs/example_access.log" common
#RewriteEngine On
#RewriteCond %{HTTP_HOST} ^www.example.com [OR]
#RewriteCond %{HTTP_HOST} ^example.com
#RewriteCond %{REMOTE_ADDR} !##.##.##.## [NC]
#RewriteCond %{REMOTE_ADDR} !##.##.##.## [NC]
#RewriteRule ^/(.*)$ https://secure.example.com/$1 [R=301]
#Redirect 301 / https://secure.example.com

SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /etc/ssl/certs/example.crt
SSLCertificateKeyFile /etc/ssl/private/example.key
SSLCertificateChainFile /etc/ssl/certs/sub.class1.server.ca.pem
SSLCACertificateFile /etc/ssl/certs/ca.pem
CustomLog /srv/http/logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
<Directory /srv/http/example>
                    RewriteEngine On
                    RewriteBase /
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteCond %{REQUEST_FILENAME} !-d
                    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]                                       
                    DirectoryIndex index.php
                    AddHandler cgi-script .cgi .pl
                    Options ExecCGI Indexes FollowSymLinks MultiViews +Includes
                    AllowOverride None
                    Order allow,deny
                    allow from all
        </Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin busted@example.com
    DocumentRoot "/srv/http/example"
    ServerName example.com
    CustomLog "/srv/http/logs/example_access.log" common
RewriteEngine On
#RewriteCond %{REMOTE_ADDR} !##.##.##.## [NC]
#RewriteCond %{REMOTE_ADDR} !##.##.##.## [NC]
RewriteCond %{HTTP_HOST} ^example.com [OR]
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule ^/(.*)$ https://secure.example.com/$1 [R=301]

<Directory /srv/http/example>
                    RewriteEngine On
                    RewriteBase /
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteCond %{REQUEST_FILENAME} !-d
                    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]                                       
                    DirectoryIndex index.php
                    AddHandler cgi-script .cgi .pl
                    Options ExecCGI Indexes FollowSymLinks MultiViews +Includes
                                        AllowOverride None
                    Order allow,deny
                    allow from all
      </Directory>
</VirtualHost>

The portion to that is not working is the RewriteCond %{REMOTE_ADDR} !##.##.##.## [NC]. I'm not sure what i'm doing wrong, I've tried this a number of ways i've found through google, but to no avail. Any  suggestions? Critique on cleaning up the vhost would be much appreciated as well.

Offline

#2 2011-09-08 07:43:06

satanselbow
Member
Registered: 2011-06-15
Posts: 538

Re: modrewrite do not redirect certain IPs

Do you own the "example.com" domain? or have you edited the file for privacy? If you are using example.com to test without full access and control of it's features you are going to get weird results sad

It would also more helpful to see any error / access logs in addition to your existing config wink

Offline

#3 2011-09-08 10:06:56

gnarliprime
Member
Registered: 2011-09-01
Posts: 11

Re: modrewrite do not redirect certain IPs

thanks for replying. yes, anything referencing 'example' has been redacted. I'm not sure which logs would be best to provide, all of the error logs for the domain and for httpd haven't had anything logged to them since last month. Let me know what would be helpful and if applicable, a grep for pertinent info

Offline

Board footer

Powered by FluxBB