LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Apache Migration/Compatibility > htaccess Rewrite question: file renaming

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2010, 12:30 PM
frankvh frankvh is offline
New Member
 
Join Date: Jul 2010
Posts: 8
Default htaccess Rewrite question: file renaming

My apologies for a noob question, but I've put a lot of time and googling into this yet I still haven't solved it. So help please!

I have a index.html file which is auto-generated by my tools (hence I don't want to manually rename it, because then I'd have to manually rename it every single time...) which contains PHP code. So I need to push it through the PHP parser. But only that one file.

In Apache in the .htaccess file I can do this:

<Files frankandcolleen/index.html>
RemoveHandler .html
AddType application/x-httpd-php .html
</Files>

This does not work on litespeed; my webhost tells me their litespeed doesn't support the Files directive.

I thought perhaps a rewrite might do the trick. Just to rename the file. Maybe something like this:

RewriteEngine on
RewriteRule frankandcolleen/index.html frankandcolleen/index.php [L]

This doesn't work either. Probably for a whole bunch of reasons...

Right now as an interim measure I'm doing this:

RemoveHandler .html
AddType application/x-httpd-php .html

This works, but it forces every single html file through the PHP parser, which is both slow, and CPU intensive on the server.

How do I push that html file, and only that file, through the PHP parser? Or rename that html file into a php file?

Thanks!!!
Reply With Quote
  #2  
Old 07-28-2010, 06:52 PM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,297
how about put
Quote:
cp frankandcolleen/index.html frankandcolleen/index.php
somewhere so your rewrite rule wil work:
Quote:
RewriteEngine on
RewriteRule frankandcolleen/index.html frankandcolleen/index.php [L]
Reply With Quote
  #3  
Old 07-28-2010, 09:19 PM
frankvh frankvh is offline
New Member
 
Join Date: Jul 2010
Posts: 8
Thanks, I can see that idea, but where to put it? The copy command is not permitted in .htaccess (although I'll confess I tried it anyway). Create a cron job and have it execute every hour? This needs to still work when the index.html file is automatically updated by the tools, which is why I really don't want to do anything manually.

It seems strange to me that something that can be done so simply in apache can't be done in litespeed? I've gotta be missing something here.
Reply With Quote
  #4  
Old 07-28-2010, 11:17 PM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,297
questions:
1.how and how often do you update index.html?

2.are there any other .php/.html files under frankandcolleen folder?
Reply With Quote
  #5  
Old 07-29-2010, 07:19 AM
frankvh frankvh is offline
New Member
 
Join Date: Jul 2010
Posts: 8
Quote:
Originally Posted by NiteWave View Post
questions:
1.how and how often do you update index.html?

2.are there any other .php/.html files under frankandcolleen folder?

1) Every 2 or 3 weeks.

2) There are a large number of pure html files (a little over a thousand I think) but index.html is the only html file containing PHP code. There are also three .php files.
Reply With Quote
  #6  
Old 07-29-2010, 10:23 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
Force index.html as MIME type "application/x-httpd-php"
RewriteRule frankandcolleen/index.html - [T=application/x-httpd-php]
Reply With Quote
  #7  
Old 07-29-2010, 11:23 AM
frankvh frankvh is offline
New Member
 
Join Date: Jul 2010
Posts: 8
Quote:
Originally Posted by mistwang View Post
RewriteRule frankandcolleen/index.html - [T=application/x-httpd-php]
Tried it, with and without the hypen "-" in the middle; sorry, didn't work.

Currently the only thing that's working is the global:
AddType application/x-httpd-php .html

The thing that bugs me is, doesn't RewriteRule have a really crazy syntax? Well I think it does for apache - no idea about differences for litespeed.
www . webforgers.net/mod-rewrite/mod-rewrite-syntax.php
So I wonder if you can even just type in filenames like that. I've been attempting variations on this kind of a theme:

RewriteRule ^frankandcolleen/index\.html$ frankandcolleen/index\.html [T=application/x-httpd-php, L]

No luck.
Reply With Quote
  #8  
Old 07-29-2010, 11:49 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
I do not think the rule really matches the request. You need to put .htaccess under directory "frankandcolleen", use rule
Quote:
RewriteRule index.html - [T=application/x-httpd-php]
Reply With Quote
  #9  
Old 07-29-2010, 02:53 PM
frankvh frankvh is offline
New Member
 
Join Date: Jul 2010
Posts: 8
Thanks for the suggestion, but is there any chance one of the litespeed staff could actually try this? Because none of these great suggestions, or any variations of them I try, are actually working.

Thanks! I really do appreciate the help.
Reply With Quote
  #10  
Old 07-29-2010, 03:15 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
Yes, I tried it in our lab, it works well.
Maybe .htaccess was not enabled, rewrite engine is not enabled or you used wrong URL to test it.
The rule only works with URL ending with "index.html", if you using URL like "...frankandcollen/" it wont work.
Reply With Quote
Reply

Tags
htaccess, mod_rewrite, rewrite

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:26 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.