Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

A simple (probably stupid) question: is it possible to show different pages for www and non-www versions of a website?

I mean for example, will show the content in /mainfolder and will show the content in /secondfolder.

I don't want to redirect, like if the user goes to he will be redirected to - I don't want that, I just wanna know how to show 2 different index.html files, one for the www version of the website and one for the version without www.

Or if possible, how can I create the www subdomain in cPanel (as it won't let me) - any way to override this?


I tried this .htaccess edit and it worked partially:

RewriteCond %{HTTP_HOST}
RewriteRule ^(.*)$ [P]

It now shows the contents of when users access however it doesn't load the CSS of the page - any way to fix this?

share|improve this question

2 Answers 2

Yes, this is definitely possible. But please note that, by convention, is just an alias for So, what you describe is not at all standard and violates most users' expectations. It also runs at least some risk of search engine penalties. So, in my opinion, it is not a good idea, but yes, it's possible.

Exactly how you do it depends on the server and/or scripting technology. For example, you could do it with Apache, which would look like this (in a .htaccess file):

RewriteCond %{HTTP_HOST} www\.
RewriteCond %{REQUEST_URI} !^/whatever/?
RewriteRule . /whatever

This would send all requests for to /whatever, but would not affect requests on This is probably overly simplistic for what you want, but you haven't provided a lot of detail.

You can do the same thing in a scripting language like Python or PHP, but how you do it depends on what exactly you want to do.

Also, the reason you can't create a www subdomain in cPanel is that it creates it automatically.

(Edited: forgot to add the second RewriteCond to avoid a loop.)

share|improve this answer
well, if i use that htaccess redirect, if the user goes to > the address in the browser will then change to or - i don't want that. what i want is if the user goes to he will be shown a page and the address in the browser will still be; and if the user goes to he will be shown a different page and the address in the browse will still be; also is there a way to bypass cpanel and create www as a subdomain? – user3288194 Feb 9 '14 at 12:55
@user3288194: The code that Ed posted is not an "external redirect", it is an "internal rewrite" - the URL in the address bar will not change in this instance. – w3d Feb 9 '14 at 13:13
already tried that code but for some reason it redirects to (the url in the address bar changes) and it does not load the content from the /whatever folder... – user3288194 Feb 9 '14 at 15:35

Just found the solution:

RewriteCond %{HTTP_HOST} ^www\.site\.com$
RewriteCond %{REQUEST_URI} !^/folder/
RewriteRule (.*) /folder/$1
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.