Subdirectory htaccess

G

George_Fusioned

Guest
#1
Hello,

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 mydomain.com/blog), and I wish to add it's htaccess rules in order for permalinks to work correctly.

Thanks!
George
 

lsmichael

Active Member
#2
Hi George,

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

Cheers,

Michael
 
G

George_Fusioned

Guest
#3
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. mydomain.com/blog/mypost/ ) it would throw me back to mydomain.com 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 subdomain.mydomain.com I get a 503 "Service Unavailable" error. Static files (ie subdomain.mydomain.com/text.txt) 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 :(
 
#4
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.
 
S

Steven

Guest
#5
Hi, I'm facing similar issue. I have subdirectory htaccess to handle rewrite, how do manage this through openlitespeed since htaccess is not support?
eg.
./.htaccess
RewriteRule ^$ frontend/
RewriteRule (.*) frontend/$1
/frontend/.htaccess
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
./frontend/public/.htaccess
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
 
#6
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.
 
Top