I just migrated my site to the godaddy cpanel hosting and am having a problem. When a user on a mobile device visits my site (www.site.com) they are being redirected to m.site.com - which I do not have nor want to have. How can I stop this using htaccess?
Try Below:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^m.domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.m.domain.com$
RewriteRule (.*)$ http://www.domain.com/$1 [R=301,L]
For Https remove last line and add:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Related
i have to domains which DNS shows on the same server. Now I would like to make a htaccess-redirect from one Domain (old domain) to a directory on the new domain
exampl:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.ch$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.ch$
RewriteRule (.*)$ https://newdomain.ch/de/besuchen/$1 [R=301,L]
I put these file on the root of the newdomain.ch but if I open olddomain.ch it only shows me the homepage and not the side /de/besuchen
thanks for help.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
Usage: These rules will redirect all traffic from olddomain.com to newdomain.com.
How to redirect using htaccess when mobile user acces on my jpg,bmp,gif files on my site
example : i want to redirect mysite.com/media/upload/files.jpg|jpeg|bmp|gif|png into m.mysite.com/media/upload/files.jpg|jpeg|bmp|gif|png
Here is my htaccess
RewriteEngine On
RewriteRule \.(jpg|png|gif|jpeg|bmp)$ - [L]
RewriteCond %{HTTP_USER_AGENT} (mobile|android|blackberry|brew|cldc|docomo|htc|j2me|micromax|lg|midp|mot|motorola|netfront|nokia|obigo|openweb|opera.mini|palm|psp|samsung|sanyo|sch|sonyericsson|symbian|symbos|teleca|up.browser|vodafone|wap|webos|windows.ce) [NC]
RewriteRule ^(.*)$ m.mysite.com [R=302,L]
the problems is, when mobile user straight accessing http:// mysite.com/media/upload/files.jpg it still not redirect into m.mysite.com/media/upload/files.jpg
Assuming that you're checking against the correct user agents, try:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^m\.mysite\.com$ [NC]
RewriteCond %{HTTP_USER_AGENT} (mobile|android|blackberry|brew|cldc|docomo|htc|j2me|micromax|lg|midp|mot|motorola|netfront|nokia|obigo|openweb|opera.mini|palm|psp|samsung|sanyo|sch|sonyericsson|symbian|symbos|teleca|up.browser|vodafone|wap|webos|windows.ce) [NC]
RewriteCond $1 \.(jpg|png|gif|jpeg|bmp)$ [NC]
RewriteRule ^(.*)$ http://m.mysite.com/$1 [R=302,L]
I'm needing help with setting up the rewrite rules for my site.
I have one rule set up so it adds www. to my site, but I also have a mobile site that starts with m. and don't know what to put in the RewriteCond I'm not sure if there is a IF type statment...
What I currently have is...
RewriteCond %{HTTP_HOST} website\.us$ [NC]
RewriteCond %{HTTP_HOST} !m\.website\.us$ [NC]
RewriteRule ^(.*)$ http://www.website.us/$1 [L,R=301]
Thanks
Try this :
RewriteCond %{HTTP_HOST} !^(www|m)\.website\.us$ [NC]
RewriteRule ^(.*)$ http://www.website.us/$1 [L,R=301]
#ADD HTTPS TO URL
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/hd/209$
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
I'm trying to force ssl for all the pages on the site except for /hd/209
I've tried the code above but it still forces that /hd/209 to ssl
I will add a redirect for folder
redirect 301 /folder/ https://domain.com/carpinteria-aluminio-mallorca/
Clear your browser cache and restart it.
Then replace your code with this:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule (?!^hd/209)^(.*)$ https://domain.com/$1 [L,NC,R=301]
I'm using the following to redirect traffic from an old domain to a new one:
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
It works great, but I need to actually redirect traffic going directly to the old site's home page to a different location. How do I add this exception?
Try using the following:
## Redirect for home page requests
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /oldhomepage.html [R=301,L]
## Redirect for all other requests
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/oldhomepage.html
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
Depending on where you are sending the requests for the homepage, this may need to change some, but essentially, you need to check the content of %{REQUEST_URI} for each RewriteRule.
Hope this helps...