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.
- 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"
- 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>
- Run cpanel script.
root@cpanel [~]# /scripts/ensure_vhost_includes --user=username
- 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! 🙂
GENIOUS!!! Tks so much!! easy and simple… as it should be!! Fantastic!!