mod_rewrite and aliases

#1
Hi,
We use LiteSpeed in directadmin panel and it uses the Apache configuration to handle the shared services by default,
there are some alias addresses which are connected to public web programs in /var/www/html, example:
Alias /webmail "/var/www/html/webmail/"
now one of our clients wants to have this address /mail/ redirected to /webmail/ using this mod-rewrite rule:

RewriteEngine On
RewriteRule mail /webmail [L,NC]

but mentioned rule is not working and returns response 404 by browsing DOMAIN.COM/mail, seems that the "alias" rules is loaded after mod_rewrite ones

Can anybody help me make mentioned mod_rewirte work ?
thanks,
 

NiteWave

Administrator
#2
1. how about access domain.com/webmail directly ?
in cPanel, it will redirect you domain.com:2095
2.is the rewrite rule working with apache ?
 
#3
Thanks for the answer:
1. how about access domain.com/webmail directly ?
yes, it works fine when loaded in browser:

# curl -I DOMAIN.COM/webmail/
HTTP/1.1 200 OK
Set-Cookie: roundcube_sessid=j0o5l5iegegrujgrkud07k07g0; path=/; HttpOnly
Expires: Thu, 17 Aug 2017 11:22:03 GMT
Last-Modified: Thu, 17 Aug 2017 11:22:03 GMT
Cache-Control: private, no-cache, no-store, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-DNS-Prefetch-Control: off
X-Frame-Options: sameorigin
Content-Language: en
Content-Type: text/html; charset=UTF-8
Date: Thu, 17 Aug 2017 11:22:03 GMT
Accept-Ranges: bytes
Server: LiteSpeed
Connection: close

(DOMAIN.COM is replaced with the real domain name)

2.is the rewrite rule working with apache ?
yes, mod_rewrite is ok with apache and the rules are working in file .htaccess

thanks again,
 

Pong

Administrator
Staff member
#6
You can try to add/replace some alias to
/etc/httpd/conf/extra/httpd-alias.conf
and setup rewriterule/redirect there.

after the changes, the file should be copied to /usr/local/directadmin/custombuild/custom/ap2/conf/extra/httpd-alias.conf
so that it would not get overwritten by CustomBuild
with future updates, conf rewrites and so on
 
Last edited:
Top