Unable to add www prefix to my website - .htaccess

I am trying to add www prefix to my domain. My domain is developigner.com.
I have used this code in .htaccess file but still am not able to get the desired result.
Here's my .htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{http_host} ^developigner.com [nc]
RewriteRule ^(.*)$ http://www.developigner.com/$1 [R=301,nc,L]
The problem is that if I type developigner.com it gets redirected to www.your_domain.com and if I type www.developigner.com it works perfectly.
I want your_domain to be replaced by developigner
Any help would be greatly appreciated.
Thanks

It works for me as expected: developigner.com redirects to www.developigner.com.
I notice you only registered the domain yesterday. It's possible this problem is actually caused by delays in the global propagation of your domain name.

Related

.htaccess redirect with multi-subdomain

I'm currently using this rule to redirect traffic (except one url) to a new url.
It works fine when using a non www url like "subdomain.olddomain.com" but when accessing it with www like "www.subdomain.olddomain.com", I get a redirection error. This is the rule i use:
RewriteCond %{REQUEST_URI} !^/exception($|/)
RewriteRule ^(.*)$ https://www.newdomain.com/ [R=301,L]
What am I missing here? I'm not an expert in any way with htaccess… Thank you!
PS: I already searched for answeres but couldn't find any matching my subdomain issue.
Seems like I had to change some domain settings, the rule above works as expected.

Permanent redirecting to different domain via .htacces

I got two domains. Lets say dom.com and dom.net.
Now I got alias on dom.net to dom.com, so when I come to dom.net it shows me dom.com - this is set on admin's webpage.
But I need when somebody comes from dom.net redirect him to dom.com/test/example.html.
My .htacces file is blank now.
Is it possible to do this using .htacces and how can it be done?
I got it!
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} dom.net$
RewriteRule ^(.*)$ http://www.dom.com/test$1 [R=301,L]
this code redirect me to test folder but still don't know how to redirect to .html page

.htaccess redirect folder to subdomain

I've tried applying a few of the answers found on stackoverflow, but either I'm missing something or I'm plain dumb.
Basically I got a main domain name. This domain already has a non-www redirect. So http://domain.com becomes http://www.domain.com. This domain also has a mobile version found inside the the 'm' folder. So accessing the domain name like http://www.domain.com/m/ works and so does http://m.domain.com. What I'm trying to achieve is simple: anyone whom goes to the site via http://www.domain.com/m/, or http://www.domain.com/m/about should be redirected to the subdomain version so to http://m.domain.com or http://m.domain.com/about in the second case listed above.
Whatever I tried implementing ended up with errors, either I managed to disable direct access to m.domain.com, but it worked via domain.com/m/, or redirect loops.
Thanks!
You can use this code in your DOCUMENT_ROOT/.htaccess file of domain.com main .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?(domain\.com)$ [NC]
RewriteRule ^m/(.*)$ http://m.%1/$1 [L,NC,R=302]
# non-www to www
RewriteCond %{HTTP_HOST} !^(m|www)\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,NC,R=302]

.htaccess : Rewriting initial output back into subdomain

I have the following htaccess.
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www|m)\.DOMAIN\.com$
RewriteCond %{HTTP_HOST} ^([^\.]+).DOMAIN.com$
RewriteRule ^(.*)$ http://DOMAIN.com/index.php?id=%1 [NC,QSA,L,R=301]
The problem is that although it works I need it to still use the subdomain as the URL. So basically now I'm trying to rewrite DOMAIN.com/index.php?id=%1 back into SUDOMAIN.DOMAIN.com so the user sees the subdomain they requested on the address bar and not the http://domain.com/index.php?id=user
I'ver tried all sorts of things but always end up with some sort of infinite loop. Please help!
I already have a wildcard subdomain set up. In conjunction with the htaccess shown above.
The submain doesn't stick, it rewrites itself into the long string shown above. But what im trying to do is get the url ro remain subdomain.domain.com unfortunately the link you posted does peretty much the same as what I have posted above, doesn't really seem to be able to get the sub-domain to stick.
Any ideas?
Not sure if you figured it out yet, but your last line (I believe) should be this:
RewriteRule ^(.*)$ index.php?id=%1 [NC,QSA,L,R=301]
If that does not work try this:
RewriteRule (.*) index.php?id=%1 [NC,QSA,L,R=301]
No expert but I have subdomains working from some other code I found. Hope it helps.
You need to change your DNS settings before. (A record)
There is already an answer for that question.

htaccess command to prevent master site access via subdirectory?

I have hosting setup with a master domain (mapped to the web root) and then a number of addon domains (each with their own folder within the web root). At the moment you can visit www.masterdomain.com/addondomainsubdir and reach the same page as you would if you visited www.addondomain.com (which maps to /public_html/addondomainsubdir). I want to prevent this so if you visit www.masterdomain.com/addondomainsubdir then it will do a 301 redirect to www.addondomain.com. The new addondomain.com site is a single page site so it does not have to map any additional pages.
Adding rules to the htaccess file in the web root does notaffect anything as the subdir exists which is wierd as i thought the htaccess command should work even if there is a matching subdir (i've tried the following which works when there's no matching subdir):
RewriteRule ^addondomainsubdir?$ http://www.addondomain.com [NC,R=301,L]
Logically given it's reaching this directory I figure i need to add a command within the htaccess file in the addondomainsubdir directory however nothing appears to have any effect (i've got various other rules setup and they work fine).
I would be massively grateful if anyone explain the best way to rectify this?
Thanks so much for your help,
Dave
I know this is an old post, but it has never been successfully answered. So for all of you finding this via search, this should do what the OP is asking.
Add this line to your .htaccess file:
redirect permanent /addondomainsubdir/ http://www.addondomain.com
Try these rules in your .htaccess:
Options +FollowSymlinks -MultiViews
RewriteEngine on
# for http
RewriteCond %{HTTP_HOST} ^(www\.)?masterdomain\.com$ [NC]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^([^/]+)/?$ http://www.$1.com/ [R=301,L]
# for https
RewriteCond %{HTTP_HOST} ^(www\.)?masterdomain\.com$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^([^/]+)/?$ https://www.$1.com/ [R=301,L]
Instead of putting a rule in your main .htaccess, I would make make a .htaccess for each add-on domain, putting each one in the respective subdirectory.
RewriteEngine on
RewriteCond %{HTTP_HOST} masterdomain\.com$ [NC]
RewriteRule ^addondomainsubdir(.*)$ http://www.addondomain.com/$1 [R=301,L]

Resources