Rewrite urls in WHM for Symfony plugin

Alvaro Flano

Member
Apr 24, 2015
7
0
51
Santiago
cPanel Access Level
Root Administrator
I've written a WHM plugin to manage blacklist/whitelist of outgoing IPs for our Exim server (and other spam control features we use). This plugin is written in PHP using the Symfony framework. This framework relies on the ability to rewrite URLs so all requests are handled by a single index.php file. This is usually done using Apache's .htaccess file with mod_rewrite. I now realized that WHM runs its own webserver. Is there a way/trick/hackity hack to achieve the same result as Apache's mod_rewrite using cpsrv and CGI?
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
79
458
cPanel Access Level
Root Administrator
The internal webserver (cpsrvd) can handle PHP applications. There is no mod_rewrite like functionality. If your application relies upon URLs that look like /service/mail/block/1.2.3.4 or /index.php/service/mail/block/1.2.3.4 then it may not work. If the URLs can be handled as traditional GET parameters (e.g. /index.php?service=mail&block=1.2.3.4), then it should work.
 

Alvaro Flano

Member
Apr 24, 2015
7
0
51
Santiago
cPanel Access Level
Root Administrator
My current workaround is to create an index.php file on each of the expected locations (so the server doesn't thow a 404) and it changes the request's URI and requires my main index.php. This seems to be plausible so far.

-- UPDATE --
It actually works. This way I have now my Symfony app running as a WHM Addon. Some other few adjustments must be made, but at the end it works great.
 
Last edited: