I've read a tonne of questions on this and tried a few solutions, but I'm just not getting the results I want.

I'm currently using:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^cp\.example\.net
RewriteRule ^(.*)$ http://example.net/gamepanel/public/$1 [L,NC,QSA]

Which doesn't quite work as intended. When I navigate to cp.example.net I am redirected to http://example.net/gamepanel/public/

What I want to have happen is for cp.example.net to show the content at http://example.net/gamepanel/public, whilst showing the subdomain in the URL.

Also cp.example.net/user should show content from example.net/gamepanel/public/user

Some help on achieving this would be much appreciated!

  • You can't simply do cross-domain (internal) rewrites like this. You'll need to set up your server as a proxy and use mod_proxy (which itself comes with security issues). Is this your own server?
    – MrWhite
    Commented Sep 14, 2015 at 8:56
  • 1
    It is my own domain. After continuing to research I found that associating the sub domain was the better way to go
    – James
    Commented Sep 14, 2015 at 8:59

2 Answers 2


After more digging, associating the sub domain with my directory was the better way to do this:

<VirtualHost *:80>
        ServerName cp.example.net
        DocumentRoot /var/www/gamepanel/public
        <Directory /var/www/gamepanel/public>
            Options -Indexes

Untested... but should work

#Options +FollowSymLinks
Options +SymlinksIfOwnerMatch

RewriteEngine on
RewriteCond %{HTTP_HOST} ^cp.example.net$ 
RewriteRule ^(.*)$ http://example.net/gamepanel/public/ [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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