WWW works, no www does not work - .htaccess

Quick domain question:
A clients site: www.workingwardrobes.org, does not work if I take off the www. .Someone told me that I have to do a DNS change and add the non www. with the same ip as the www. However, can't I just fix this with some sort of htacess?

Unlikely. If the non-www URL isn't hitting the server, it won't hit your .htaccess and that's what it sounds like is happening.

Unless you do a dns change you can't do this. But after you have done that you can redirect www version to non www version or vice versa.

It looks like you have a DNS entry for both www and non-www (maybe you just added it). Anyway, they both work. However, you should really pick one as the "standard", for seo reasons and just to be consistent. You can do this with .htaccess rules.
There are many questions and answers here on SO, such as:
Generic htaccess redirect www to non-www
This discusses both ways, depending which one you want.

Related

stop the Redirect from www.domain.com todomain.com

I want to stop the Redirect from www.domain.com to domain.com
I need www.domain.com " work only no redirect "
and domain.com " work only no redirect >> how do it? on htaccess with Cpanel**
It really depends on a lot of factors. Some of the main ones are:
What kind of application do you use?
Do you have any Rewrite Rules inside your .htaccess?
The first one is important as some applications do require to be re-configured to work with the new URL, either "www" or "non-www".
Depending on your current .htaccess rewrite rules, you might want to add/remove rules to achieve that.
Certainly, your host should be able to also help with this one.

Another .htaccess redirect case

I have a site where mydomain.com and mydomain.com/frontpage serves the exact same content.
Socalled SEO experts tell me it is very bad to have the same content on different addresses. Google will cast upon me a terrible fate.
So I thought fine, I'll just redirect mydomain.com to mydomain.com/frontpage, but I'm failing miserably. I just can't wrap my head around htaccess commands.
I need to have visitors who visits mydomain.com or www.mydomain.com to be redirected to www.mydomain.com/frontpage in a way to that it becomes visible in the browser address field.
BUT nothing else must be redirected.
For example, www.mydomain.com/anotherpage must still be there.
My .htaccess is already full of a lot of rewrite rules that redirects all of these user-friendly addresses to the real urls (index.php?pageid=341) etc. So I'm thinking I would first redirect mydomain.com to mydomain.com/frontpage and then let another RewriteRule later make sure that mydomain.com/frontpage actually points to index.php?pageid=341.
But mydomain.com => mydomain.com/frontpage must be a visible redirect, while all the other rewrite rules are hidden from the user.
How does the Redirect or RedirectMatch or RewriteRule look like, that redirects visitors from www.mydomain.com to www.mydomain.com/frontpage while keeping other addresses like e.g. www.mydomain.com/anotherpage ?
Thanks.
You can insert this new rule just below RewriteEngine On line:
RewriteRule ^/?$ /frontpage [L,R=301]

.htaccess 301 redirect for thousands of entries or RewriteMap

I have a site with thousands of pages that need to be redirected. I was thinking of using a 301 redirect in my .htaccess, but I'm just afraid that this will be very inefficient.
Would having a .htaccess with thousands of lines (there is no way to have a re-write rule, they have to be mapped one by one), mean that every time someone accesses one of our pages, they have to read the entire .htaccess? Is that a bad thing? This sit is in a shared host.
I saw a previous answer here about using RewriteMap. How is that different than having the 301 redirects?
Thanks
For simple page redirects 301 is the best and it's very fast. RewriteMap is for more complex rewrite functions or doing very specific rewrite tasks.
Before black listing your pages server side, I would try remapping with your application first.
If you set up the redirect with .htaccess those pages will be dead to Google which of course may or may not be a bad thing. Basically once Google indexes those redirects there really is no going back (SEO).
In short redirect wisely.

Behaviour of domains and subdomains for accessing a URL

Why does analytics.google.com works while www.analytics.google.com does not ??
David's comment above is accurate. I wanted to expand upon this a little to clarify your thinking of www.
www. is a subdomain like any other. Whether you use analytics. or www. or whateveryouput., they're all still just subdomains that are created for the domain in question.
David answers correctly that the reason www.analytics. doesn't work is because the subdomain analytics. doesn't have a subdomain www..
I think it's important to know that there's nothing particularly special about the www. subdomain compared with any other subdomain.

Unable to show siteA's content at siteB by domain masking

I have a domain www.siteA.com, which uses Joomla, while the domain www.siteB.com is empty.
I would like to show the content of the domain www.siteA.com at www.siteB.com.
I tried to solve the problem first by making a domain redirection by .htaccess, but I could not show SiteA's content at SiteB.
How can you show the contents of mysiteA.com at mysiteB.com by domain masking in .htaccess?
You really should be doing this by CNAME-ing the domain, but if you really want to use .htaccess you can do what #Unkwntech suggests
Edit: It would just look like
www.siteB.com CNAME www.siteA.com
Whichever way you do it (CNAME or htaccess) you're probably going to get an SEO penalty for duplicate content.
RewriteEngine On
RewriteRule ^.*$ http://www.siteA.tld/$1 [NC]
This should rewrite every request to siteA.

Resources