I've a website hosted on an Apache server which hosts other domains. Therefore, I can't access the Apache configuration.

On our website, I've several domains. For one of them (domain example.com), I've created a subfolder (mysub), and created a subdomain (ww2) to end in this subfolder. I can't use www as I don't have access to the Apache config and therefore, I can't change the DocumentRoot folder.

I've created a rewriteurl to move all requests going to the domain (example.com)

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/ww2\.example\.com\/" [R=301,L]

This works well. Question, is it possible to cheat and display www in the browser instead of ww2?

I guess not and I couldn't find anything related on Google. I know that best workaround would be to have a dedicated website but for now, I can't do it. If a guru has a thought or a better idea as workaround, please share.

1 Answer 1


...is it possible to cheat and display in the browser url www instead of ww2?

No, you can't "fake" the URL (ie. hostname) in that way.

However, you don't necessarily need to and you don't necessarily need access to the server config to change the document root either. Instead, you could internally rewrite the request for the www.example.com host (ie. the www subdomain) to the mysub (or even www) subdirectory. The ww2 subdomain is not required.

For example:

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteRule !^mysub/ /mysub%{REQUEST_URI} [L]

RewriteRule ^/?$ "http\:\/\/ww2\.myadditionaldomain\.net\/" [R=301,L]

Incidentally, this would only "redirect" requests for the root. It wouldn't redirect /foo for instance.

(Also, no need to backslash escape slashes, colons and dots in the RewriteRule substitution. This is not a regex. But even if it was a regex, slashes and colons carry no special meaning in Apache PCRE regex. This is very cPanel-esque.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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