Subdirectory htaccess




I have successfully applied my htaccess rules to the root directory of a virtual host, but how can I do the same for a subdirectory? In my case I have a WordPress installation under a subdirectory (eg, and I wish to add it's htaccess rules in order for permalinks to work correctly.



Active Member
Hi George,

This would be a "context". You can set up contexts in your virtual configs: WebAdmin > Configuration > Virtual Hosts > your vhost > Context




Thank you for the tip Michael, unfortunately I could get this to work with contexts.
I mean I created a new context, enabled rewrites, disabled "Rewrite Inherit" and pasted my rules in "Rewrite Rules".
However when I would try to access a permalink'd URL (ie. ) it would throw me back to with a 404 error.

So I decided to create a new virtual host and host the WordPress files there, but now I can't get PHP to work (I think).
When I try to visit the blog at I get a 503 "Service Unavailable" error. Static files (ie work fine.
I practically copied the "External App" and "Script Handler" settings from my other virtual host, and only changed the LiteSpeed SAPI App Name and Address.

So my main domain has:
LSAPI Address: uds://tmp/lshttpd/domain1_lsphp.sock
and the subdomain has:
LSAPI Address: uds://tmp/lshttpd/subdomain_lsphp.sock

All other settings are identical. The error log also doesn't help much :(
how about simple php page, for example phpinfo.php ?

you can modify "External App" name slightly, to avoid same name as server level "External App", and modify "Script Handler" accordingly.


Hi, I'm facing similar issue. I have subdirectory htaccess to handle rewrite, how do manage this through openlitespeed since htaccess is not support?
RewriteRule ^$ frontend/
RewriteRule (.*) frontend/$1
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]

How do I handle multiple level .htaccess through openlitespeed? also can you please show us how to use folder specific htaccess using the admin panel
I think one way is to combine all subdirectory rewrite rules into 1 virtual host level rewrite rule, this is an efficient way for server to handle all rewrite rules.
for your case:
1. set document root to current_doc_root/frontend/public
2. virtual host level rewrite rules:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /index.php?_url=/$1 [QSA,L]

see if these works well.