How do I redirect /CPanel URL -> domain:2222

First create a directory named cpanel in /var/www/html. Then make a index.php file in that directory with the contents:

<?php header("Location: http://yourhost.com:2222/"); ?>

Then edit the /etc/httpd/conf/httpd.conf file and add the alias:

Alias /cpanel /var/www/html/cpanel/

I've not checked this myself but I think it will work.

Greets,
ja3
 
how if I want to redirect domain.com/cpanel to domain.com:2222 ?
it still use the current domain without redirect to hostname
 
how if I want to redirect domain.com/cpanel to domain.com:2222 ?

Code:
 cd /usr/local/directadmin/data/templates/custom
 cp ../virtual_host2.conf .


Add the following near the bottom of the file /usr/local/directadmin/data/templates/custom/virtual_host2.conf beneath |CUSTOM4|

Code:
Alias /cpanel /var/www/html/redirect.php

Code:
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
 /usr/local/directadmin/dataskq d
 service httpd restart
 
Code:
 cd /usr/local/directadmin/data/templates/custom
 cp ../virtual_host2.conf .


Add the following near the bottom of the file /usr/local/directadmin/data/templates/custom/virtual_host2.conf beneath |CUSTOM4|

Code:
Alias /cpanel /var/www/html/redirect.php

Code:
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
 /usr/local/directadmin/dataskq d
 service httpd restart

thank you ..
 
I tried this step, but I got

"bash: Alias: command not found"

Any idea please?
 
It may be overwritten there when DA updates Apache, so you may want to follow the instructions and add it to the file specified ( Add the following near the bottom of the file /usr/local/directadmin/data/templates/custom/virtual_host2.conf beneath |CUSTOM4|).

But I can totally see why you'd run that as a command since it was posted in a code block. I'll try to format instructions better in the future. :)
 
Last edited:
Is there a way to achieve this with OLS? As followed the steps but it appears to break OLS as was optimistically hoping code would have been rewritten on the fly and worked. But almost as expected it didn't.
 
Is there a way to achieve this with OLS? As followed the steps but it appears to break OLS as was optimistically hoping code would have been rewritten on the fly and worked. But almost as expected it didn't.

For OLS edit in /usr/local/lsws/conf/httpd-alias.conf
 
Back
Top