IP redirect
3 naročniki
3 naročniki
Zdravo
Kako lahko v htaccessu redirectam specific IP na določeno domeno?
Našel sem neke primere na netu,pa noben ne deluje
Hvala
7 odgovorov
To more delat:
RewriteEngine On
If it's not your IP address
RewriteCond %{REMOTE_ADDR} !^1.2.3.4$
Redirect /abc to example.com/abc.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
1.2.3.4 je IP
ne dela ..
tole je WP htaccess
RewriteEngine On
# If it's not your IP address
RewriteCond %{REMOTE_ADDR} !^89\.212\.151\.31$
# Redirect /abc to example.com/abc.
RewriteRule ^(.*)$ http://disney.com/$1 [R=301,L]
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
krejzi:
To more delat:RewriteEngine On
If it's not your IP address
RewriteCond %{REMOTE_ADDR} !^1.2.3.4$
Redirect /abc to example.com/abc.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
1.2.3.4 je IP
On želi samo določen IP preusmeriti, ne pa vse ostale, torej:
RewriteCond %{REMOTE_ADDR} ^1.2.3.4$
vrzi kodo na drugo mesto:
BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
END W3TC Browser Cache
BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TCENC:gzip]
RewriteCond %{HTTPCOOKIE} w3tcpreview [NC]
RewriteRule .* - [E=W3TCPREVIEW:preview]
RewriteCond %{REQUESTMETHOD} !=POST
RewriteCond %{QUERYSTRING} =""
RewriteCond %{REQUESTURI} \/$
RewriteCond %{HTTPCOOKIE} !(commentauthor|wp-postpass|w3tcloggedout|wordpressloggedin|wptouchswitchtoggle) [NC]
RewriteCond "%{DOCUMENTROOT}/wp-content/cache/pageenhanced/%{HTTPHOST}/%{REQUESTURI}/index%{ENV:W3TCPREVIEW}.html%{ENV:W3TCENC}" -f
RewriteRule .* "/wp-content/cache/pageenhanced/%{HTTPHOST}/%{REQUESTURI}/index%{ENV:W3TCPREVIEW}.html%{ENV:W3TCENC}" [L]
</IfModule>
END W3TC Page Cache core
BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
dizni
RewriteCond %{REMOTE_ADDR} ^89.212.151.31$
RewriteRule ^(.*)$ http://disney.com/$1 [R=301,L]
/dizni
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUESTFILENAME} !-f
RewriteCond %{REQUESTFILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
END WordPress
ok .. malo dlje sem ze s popravljeno kodo ...
sedaj pa mi vrze ven error
The requested URL /wp-content/cache/pageenhanced/www.mojdadomena.si/index.html_gzip was not found on this server.
hja .. tale koda deluje čist fajn
# dizni
RewriteCond %{REMOTE_ADDR} ^89\.212\.151\.31$
RewriteRule ^(.*)$ http://disney.com/$1 [R=301,L]
# /dizni
kako pa to urediti glede na to, da WP oz. Woocommerce po svoje "šlihta" htaccess in za vsako zbriše to kodo?