Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite code for apache 1.3.9 doesn't work on apache 2?

or is it something i've overlooked elsewhere

         

jamie

8:29 am on May 14, 2004 (gmt 0)

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



hi,

i am using the exact same mod_rewrite code i used on apache 1.3.29 on our new apache 2 server but it's not working as it should.

i have set options and allowoverride to all, and a simple redirect:
RewriteRule music.htm music2.htm [L]
works fine.

however when i try to redirect all non-existing files (code which works perfectly on apache 1.3.29) to my html.php script to generate the page:
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME}/index.html !-s
RewriteCond %{REQUEST_URI} !html\.php
RewriteRule ^(.*)$ html.php/$1 [L]

it returns a File does not exist: /var/www/sites/mydomain.com/html.php/music.htm

does anyone have any clues as to why that might be? much appreciated!

ukgimp

8:32 am on May 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



is mod_rewrite enabled?

Ask your host or put this into a page and see if it on.

<?
phpinfo();
?>

jamie

8:42 am on May 14, 2004 (gmt 0)

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



hi ukgimp,

yes all working. it is a dedicated server which i set up myself, and as mentioned above a simple mod_rewrite works fine

so i know mod_rewrite is working,
i know php is working
i know my scripts are working because i made the whole site on my dev box (lamp - apache 1.3.9) before uploading.

could it be a permissions thing?

gergoe

8:44 am on May 14, 2004 (gmt 0)

10+ Year Member



i guess the html.php is a regular php file, which processes the html file from the query string, if so, then change the RewriteRule to

RewriteRule ^(.*)$ html.php?page=$1 [L]

so your php page will get the name and the path of the requested html file in the
page
parameter.

ukgimp

8:57 am on May 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Jamie

>>yes all working. it is a dedicated server which i set
>>up myself, and as mentioned above a simple
>>mod_rewrite works fine

Missed that sorry. ooops

jamie

9:00 am on May 14, 2004 (gmt 0)

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



hi gergoe,

i just tried that and it works. thanks very much!

why should code which is valid for apache 1.3.9 'html.php/$1' *not* work on apache 2?

is it something to do with the server environment variables? hmmm very confusing.

anyway thanks both of you for suggestions :-)

gergoe

9:10 am on May 14, 2004 (gmt 0)

10+ Year Member



well, *this* rewriting which you posted is not supposed to work on apache 1.3 either. what i think is happened that you had some more rules previously, which you forgot to set in your apache 2 installation. something like this:

RewriteRule htmp.php/(+*) html.php?page=$1

i don't know, but if you haven't got additional RewriteRules i think it would not have been working. just consider what the somepath/html.php/music.html means; music.html in the html.php directory below somepath. if you haven't got such a directory then apache throws a 404 immediately.

jamie

10:42 am on May 14, 2004 (gmt 0)

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



hi gergoe,

thanks for explaining. i am still confused as to why my hack works, because there are no other rewrite rules

still it is good to know what it should be :-) and is a simple matter to recode my script.

many thanks!