Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule for two or more file types/extensions

         

smallcompany

7:25 am on Jan 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



We've come into position to do rewrite for files with HTML and PHP extensions.

Pages are static HTML, but in order to get some PHP code working inside those HTMLs, we did this:

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

So far so good.

Then, since we parse HTML with some Perl based parser, I had to do this to get it work:

RewriteRule ^(.*)\.html$ parser.cgi?file=$1 [QSA,L] - old code for HTML files
RewriteRule ^(.*)\.php$ parser.cgi?file=$1 [QSA,L] - new code for PHP files

I wonder if this can be done in one line. How do we get this if we have multiple file extensions that we want to rewrite?

Thanks

jdMorgan

8:08 pm on Jan 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteRule ^([^.]+)\.(html¦php)$ parser.cgi?file=$1 [QSA,L]

It is time to go study the regular expressions tutorial cited in our forum charter now...

Replace the broken pipe "¦" character with a solid pipe before use; Posting on this forum modifies the pipe character.

Jim

smallcompany

5:47 am on Feb 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks very much.

The time was long time ago. I'm late while pushed (by business) to seek advice in this way.

Those are almost at my door:

1. CGI Programming with Perl
2. Perl Cookbook
3. Php Cookbook
4. Regular Expression Pocket Reference

I already have some but they don't bother about such stuff (regular expression).

For sure, I did not order anything about Apache, for the sake of getting my .htaccess right.

Any suggestion?

Thanks again.

P.S.
I have bookmarked the charter from the forum. I know... you'll say "read it". I will. :)