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

ja3

Verified User
Joined
Mar 28, 2004
Messages
51
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
 

aldhy

Verified User
Joined
Jul 20, 2019
Messages
12
how if I want to redirect domain.com/cpanel to domain.com:2222 ?
it still use the current domain without redirect to hostname
 

scriptkitty

Verified User
Joined
Jul 10, 2019
Messages
65
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
 

network

Verified User
Joined
Jul 7, 2019
Messages
43
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 ..
 

tons613

New member
Joined
Dec 10, 2019
Messages
2
I tried this step, but I got

"bash: Alias: command not found"

Any idea please?
 

scriptkitty

Verified User
Joined
Jul 10, 2019
Messages
65
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:
Top