Forum Moderators: phranque

Message Too Old, No Replies

IE + PHP REQUEST URI, + Mod Rewrite Problem?

Can't even figure out if it's a client or server problem.

         

JAB Creations

3:41 pm on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I finally decided to try and track down one of the many bugs that only seems to effect IE. It's a strange combination of PHP's $_SERVER['REQUEST_URI'] variable, Internet Explorer, and Apache mod rewrite.

For some reason IE treats the last JavaScript file inside the head element on the next version of my site as $_SERVER['REQUEST_URI']. The only thing this effects is what page IE users are redirected to after signing in and it currently redirects to the JavaScript file. When I comment the script element it seems to work perfectly fine...the thing is there is nothing PHP related to that JavaScript file...so I'm absolutely at a loss there, why wouldn't the stylesheet served just before the JavaScript file not take it's place after I commented the JavaScript file out? Both are in directories with exceptions in the .htaccess file. I can only presume it's some buggy behavior with IE...it's almost like there is some kind of trend!

Here is my .htaccess file with the relevant code...I've spent the past few hours searching and it seems to be a very vague Apache bug apparently...though if it was an Apache bug then it would effect all browsers right? I'm totally thrown off if it's specifically IE or an IE+something else sort of bug? Is my mod rewrite written incorrectly?

- John

<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(exception1/Šexception2/Šexception1.php) - [L]
RewriteRule !\.(icoŠjpg)$ index.php

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^index\.php$ [%{SERVER_NAME}...] [NC,R=301,L]
</ifmodule>

jdMorgan

9:35 pm on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For some reason For some reason IE treats the last JavaScript file inside the head element on the next version of my site as $_SERVER['REQUEST_URI'].

I've read that ten times, and cannot find the meaning of it. JavaScript runs client-side, and server variables are handled server side, and I can't fathom "IE treats the last JavaScript file inside the head element as $_SERVER['REQUEST_URI']" (assuming I've parsed that sentence correctly).

Those JS files will indeed be fetched (along with all other page-included objects) as REQUEST URIs from your server unless they have been previously cached by the browser. As such, since they are not (apparently) in the /exception1 or /exception2 directory-path, and since they don't end with ".ico" or ".jpg", the requests for those JS files will be passed to your index.php file by your first rule. Perhaps you need to exclude .js filetypes from the rewrite as well?

All I can offer beyond that is a fix-up of your code, which likely won't make a bit of difference regarding this problem:


<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(exception1Šexception2)/
RewriteRule !\.(icoŠjpg)$ index.php
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^index\.php$ http://%{SERVER_NAM[b]E}/ [N[/b]C,R=301,L]
</ifmodule>

Note that it should not be necessary to check for exception1.php because that URL-path won't match either of the rules' patterns (it does not end in ".ico" or ".jpg" and it does not match "index\.php" either.

Your index.php to domain rewrite should end with a slash.

You can omit the <IfModule> container, unless you want this code to fail silently if mod_rewrite is not loaded on the server.

Replace all broken pipe "Š" characters with solid pipes before use.

Jim