cPanel – create directory alias on domain

Creating aliases on cpanel server is easy – for domains. But when you want to create directory alias for files outside of document root, there is no quick/click option in control panel. By directory alias I mean for example, http://mydomain.com/something. Where /something is directory that is outside of your document root – public_html of domain. Another example, you have domain mydomain.com and you want phpmyadmin to be accessible on http://mydomain.com/phpmyadmin, but phpmyadmin is installed outside of document root of  mydomain.com. You’ll need directory alias. Here is quick way to do it.

  1. Check cPanel’s Apache definition for your domain. Open configuration file /usr/local/apache/conf/httpd.conf and search for your domain in it. Then search for something like this:
    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2_2//mydomain.com/*.conf"
  2. For example above, we would do something like this:
    # Create proper directory tree
    root@cpanel [~]#  mkdir -p /usr/local/apache/conf/userdata/std/2_2/username/mydomain.com/
    # Move to created directory
    root@cpanel [~]# cd /usr/local/apache/conf/userdata/std/2_2/username/mydomain.com/
    # Create new configuration file which will contain your alias configuration.
    root@cpanel [mydomain.com]# vi mydomain.com.alias.conf
    # Add directory alias Apache definition. For example, myapplication.
    Alias /myapplication /home/username/mydomain.com/something/myapplicationdir
    <directory "/home/username/mydomain.com/something/myapplicationdir">
        AllowOverride All
        Allow from All
    </Directory>
    
  3. Run cpanel script.
    root@cpanel [~]# /scripts/ensure_vhost_includes --user=username
  4. Restart Apache

That’s it, you just created directory alias. 🙂 Application should now be accessible on http://mydomain.com/myaplication. Cpanel won’t rewrite your settings.

Of course, don’t forget to change names in steps above according to your needs! 🙂

1 Comment

Got Something To Say:

Your email address will not be published. Required fields are marked *

*

I accept the Privacy Policy

This site uses Akismet to reduce spam. Learn how your comment data is processed.

GENIOUS!!! Tks so much!! easy and simple… as it should be!! Fantastic!!

© 2024 geegkytuts.net
Hosted by SIEL


About author