Setting up External App Context

#1
Is there a way to direct only a specific file to an external app like lsphp? For example, I want to redirect /index (with no .php extension), but no other files in that directory, to php. So far, the only way I have been able to direct files to external applications is by mapping file extensions. I'm looking for something like Apache's "ForceType" directive.
 
#4
Hmmm. This isn't working for me. I set up a static context, url = "/index.html" location = "index.html", "Force MIME Type" = "application/x-httpd-php".

But the index.html page is getting served as text.
 
#6
Is there a script handler defined for ".php"? make sure to clear your browser cache.
Yes. Accesing /index.php works fine (strangely, even though there is no index.php file).

In the help for "Force MIME Type" it says all files will be served as *static files.* Is this perhaps the problem?
 

mistwang

LiteSpeed Staff
#7
OK, we will check the "Force MIME Type" configuration, let's try a different approach now, remove "Force MIME Type" configuration, set "Add MIME Type" with "application/x-httpd-php .html".
 
#8
OK, I assume you meant "application/x-httpd-php html" (without the dot), right?

That doesn't work either.

http://www.mydomain.com/ is still served as text.

but...

http://www.mydomain.com/index.html is served as a 404 page.

I wonder if there is some interaction between this context and the rewrite rules in the virtual host?

The virtual host's rewrite rules look like this:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.html
 
#9
I just discovered that if I change the context URI to "/" (instead of "/index.html") it works. But I assume that this will cause all .html files to be processed by php. I would like to set it up to process only the index.html file as php and all other html files as static html.
 

mistwang

LiteSpeed Staff
#10
Does index.html exist? I don't understand why it is served as 404, maybe you should turn on debug logging.

rewrite rules at vhost level does not have a rewrite base, you need to fix the last rewrite rule by giving the full URI.

You can force the MIME type by using rewrite rule as well.
That's another option.
 
#11
like this?

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) /index.html
 
#13
Well I have it mostly working. However, it only works if I set the context URI to "/" (instead of "/index.html"). This causes all .html files to be processed by php. I would like to set it up to process only the index.html file as php and all other html files as static html. Are you sure this is possible? LiteSpeed does not seem to like a context URL that is a file. It seems only to support directory URLs.
 
#15
That did not work either. It is the only context, so it is sequence order 1.

Here are the context settings:

URI exp:^/(index.html)?$
Location Not Set
Accessible Yes
Notes Not Set
Enable Expires Not Set
Expires Default Not Set
Expires By Type Not Set
Extra Headers Not Set
MIME Type application/x-httpd-php html
Force MIME Type Not Set
Default MIME Type Not Set
Index Files Not Set
Auto Index Not Set
Allow Override Not Set
Realm Not Set
Authentication Name Not Set
Required Not Set
Access Allowed Not Set
Access Denied Not Set
Authorizer Not Set
Add Default Charset Off
Customized Default Charset Not Set
Enable Rewrite Not Set
Rewrite Inherit Not Set
Rewrite Base Not Set
Rewrite Rules Not Set
Enable IP GeoLocation Not Set
Apache Style configurations Not Set
 
Top