mod_geoip apache2। htaccess देश के सभी पृष्ठों से एक तक पुनर्निर्देशित


0

सर्वर - अपाचे 2.4; मॉड्यूल - mod_geoip, mod_rewrite; वर्डप्रेस साइट।

मैंने mod_geoip स्थापित किया है और अब साइट के सभी पृष्ठों से https://acample.com/ ... को एक https://example.com/restricted/ में मोनाको के उपयोगकर्ताओं से कॉन्फ़िगर करने की कोशिश कर रहा है ।

पहला नियम मैं कोशिश कर रहा हूं:

    RewriteEngine On
    GeoIPEnable On
    RewriteCond% {ENV: GEOIP_COUNTRY_CODE} ^ (MC) $
    RewriteRule ^ (. *) $ Https://example.com/restricted/$1 [L]

परिणामस्वरूप, मोनाको के नागरिकों को एक त्रुटि मिलती है: ERR_TOO_MANY_REDIRECTS। इस तरह दिखता है:

www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:16 +0000] "GET / HTTP/1.1" 302 3942 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KH$
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:16 +0000] "GET /restricted/ HTTP/1.1" 302 664 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.$
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:16 +0000] "GET /restricted/restricted/ HTTP/1.1" 302 678 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebK$
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:16 +0000] "GET /restricted/restricted/restricted/ HTTP/1.1" 302 692 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) Ap$
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:16 +0000] "GET /restricted/restricted/restricted/restricted/ HTTP/1.1" 302 706 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; $
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:17 +0000] "GET /restricted/restricted/restricted/restricted/restricted/ HTTP/1.1" 302 720 "-" "Mozilla/5.0 (Windows NT 6.1; $
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:17 +0000] "GET /restricted/restricted/restricted/restricted/restricted/restricted/ HTTP/1.1" 302 734 "-" "Mozilla/5.0 (Windows N$
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:17 +0000] "GET /restricted/restricted/restricted/restricted/restricted/restricted/restricted/ HTTP/1.1" 302 748 "-" "Mozilla/5.0 (Wi$
www.example.com:443 40.108.122.138 - - [29/Jan/2019:21:41:17 +0000] "GET /restricted/restricted/restricted/restricted/restricted/restricted/restricted/restricted/ HTTP/1.1" 

आदि।

दूसरा नियम मैं कोशिश कर रहा हूं:

RewriteEngine On
GeoIPEnable On
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} (MC) [NC]
RewriteRule .* https://example.com/restricted/ [R=302,L]

परिणामस्वरूप, मोनाको के नागरिक: example.com पर जाएं - > https://irectample.com/restricted/ पर पुनर्निर्देशित - यह काम करता है; go to example.com/about/ -> अनुप्रेषित https://example.com/restricted/ - पर काम नहीं करता।

कृपया मेरी मदद करें, मेरी गलती क्या है? मोनाको के उपयोगकर्ताओं के लिए सभी पृष्ठों से एक तक रीडायरेक्ट कैसे सेट करें?

नोट: .htaccess में यह भी शामिल है:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

इसके अलावा साइट-सक्षम / example.conf में शामिल हैं:

<VirtualHost *:80>
        ServerName www.example.com
        ServerAlias example.com
        ServerAdmin support@example.com
        RewriteEngine On
        RewriteCond %{HTTPS} off [OR]
        RewriteCond %{HTTP_HOST} ^www\. [NC]
        RewriteRule ^ https://example.com%{REQUEST_URI} [L,NE,R=301]
</VirtualHost>
<VirtualHost *:443>
        ServerName www.example.com
        ServerAlias example.com
        ServerAdmin support@example.com
        RewriteEngine On
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

धन्यवाद!

हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.