thanks for reading!
I have a redirect in htaccess which redirects all the traffic to a folder /new except traffic from 111.111.111.111 that It is supossed to not redirect with this code, but doesnt work:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^myweb.org$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.myweb.org$
RewriteCond %{REMOTE_ADDR} !^111.111.111.111
RewriteCond %{REQUEST_URI} !new/
RewriteRule ^(.*)$ /new/$1 [L]
I want to go to www.myweb.org and not be redirect to /new folder, why is redirecting me? What is the error in this code? I will appreciate any help about this :)
Thank you very much in advanced!
Regards!
Related
I want to remove www from all urls of my website domain. I used following code
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
But this code redirects only http://www.example.com to http://example.com
i want http://www.example.com/abcd as http://example.com/abcd also
Please help me. your help would be appreciated. Thanks in advance.
You can use this rule in root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(example\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
Make sure to test this in a new browser.
try this
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]
I would like to redirect a subdomain to another subdomain that is not on the same domain.
Example:
subdomain.mydomain.com --> subdomain.myotherdomain.com
I've tried the following code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.domain\.com$ [NC]
RewriteRule ^(.*)$ http://subdomain.myotherdomain.com [R=301,L]
The RewriteCond doesn't seem to work...
Could you guys help me?
Thank you,
Damien
Try it this way in your subdomain root htaccess.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain [NC]
RewriteRule ^(.*)$ http://subdomain.myotherdomain.com [R=301,L]
This is my code, placed in my htaccess in the main directory of my domain. Trying to redirect country traffic (using mod_geoip) to my subdomain.
GeoIPEnable On
RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$ [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [R,L]
However, I'm getting a redirect loop error when I put it into practice. When I switch my Rewrite rule to go to domain.com and then put the file in sub.domain.com it seems to work. What is wrong with my code? Thanks!
Thanks Anubhava for your help. I looked around a bit and found this modification that seemed to do the trick. The change was made to the RewriteRule.
GeoIPEnable On
RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$ [NC]
RewriteRule !^(subdomain) http://www.subdomain.domain.com [L,R]
I put this in my .htaccess and it worked! I saw this use with redirecting with a subfolder as well.
Try this rule with an additional condition to avoid redirect when host is already sub.domain.com:
GeoIPEnable On
RewriteEngine On
RewriteCond %{HTTP_HOST} !^sub\.domain\.com$ [NC]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$ [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [R,L]
I have this situation:
When somebody goes to www.example.com, it should display www.example.com/en/
When somebody goes to www.example.fr, it should display www.example.com/fr/
Can you help me with htaccess setup?
Thank you guys!
Simple solution for .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} www.example.fr$ [NC]
RewriteRule ^$ http://www.example.com/fr/ [L,R=301]
RewriteCond %{HTTP_HOST} www.example.com$ [NC]
RewriteRule ^$ http://www.example.com/en/ [L,R=301]
I was wondering how i can redirect my users from my old domain to a new url
forexample
http://www.5.joblessbuddy.com/news.html
into this
http://www.1.joblessbuddy.hu/news.html
i did this on my htaccess but not working
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} http://www.5.joblessbuddy.com/$ [NC]
RewriteRule ^(.*)$ http://www.1.joblessbuddy.hu$1 [R=301,L]
any suggestion would be appreciated
thanks in advance
Try this:
RewriteCond %{HTTP_HOST} (www\.)?5\.joblessbuddy\.com [NC]
RewriteRule ^(.*)$ http://www.1.joblessbuddy.hu/$1 [R=301,L]
btw: mod_rewrite cheat sheet v2 is your friend.