Forum Moderators: phranque

Message Too Old, No Replies

.htaccess browser error: loop

         

Commic

12:58 pm on Aug 20, 2012 (gmt 0)

10+ Year Member



Hi,

I am using a rather old web application that offers no longer support, that (should) works fine, but ..
the browser (IE9 and FF10) reports an 'endless loop' and refuses to load the root file. The .htacces that came with the install files is like:

/////
# BEGIN app
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /loader.php [L]
</IfModule>
# END app

# BEGIN noWWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ [mydomain.com...] [R=301,L]
# END noWWW
//////

Can someone tell me what should be changed to make this .htaccess work?

Thanks a lot
JohN

lucy24

5:18 pm on Aug 20, 2012 (gmt 0)

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



Server error messages mean a problem with an internal rewrite.

Browser error messages mean a problem with an external redirect. So you need to look at anything in your htaccess that includes the [R] flag.

Oh, and on your way to posting... did you happen to notice the thread at the top of this Forum about using "example.com"? Now that you have seen your post, you will understand the reason.

The <IfModule...> envelope is unnecessary. Not the contents, just the envelope itself.

You only need one RewriteEngine On statement per file (config or htaccess).

Does the file "loader.php" really exist? What's the capture in that RewriteRule for? It doesn't seem to be used for anything. Horrible rule, anyway. Always comes with CMS boilerplate.

Commic

5:38 pm on Aug 20, 2012 (gmt 0)

10+ Year Member



@lucy24

It's a browser error, so it's pointing to an external redirect.
I understand the use of example.com and apologize. It's my first post and will not happen again.
Leaving out the <IfModule...> envelope is not solving the problem.
Left out one 'RewriteEngine On' but that did not do it either.
The loader.php is an actual existing file. It redirects to the admin of the application. That is, if not the index.php was loaded first that starts the front-end of the application.

That did the trick, the custom index.php to the front-end was missing and had to be put in place.

All working as it should now, thank you for you response.

JohN

g1smd

7:02 pm on Aug 20, 2012 (gmt 0)

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



List the redirect before the rewrite.

RewriteEngine On is needed only once.

RewriteBase isn't needed at all.

Dump the ifModule containers.

Commic

7:09 pm on Aug 20, 2012 (gmt 0)

10+ Year Member



Ok, that brings the optimized code to?:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /loader.php [L]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

lucy24

8:04 pm on Aug 20, 2012 (gmt 0)

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



List the redirect before the rewrite.

RewriteEngine On is needed only once.

RewriteBase isn't needed at all.

Dump the ifModule containers.

Tip: When you finally reach the relevant tab, hit Refresh to bring up any further posts that arrived after you opened all your tabs :)

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

The Perfect with/without Redirect is expressed as "is NOT exactly such-and-such" so in this case

... %{HTTP_HOST} !^(example\.com)?$

the ? element ("or exactly nothing") is for HTTP 1.0 requests. There are still a few around. Mainly I think from satellite internet. (Cursory glance at logs suggests that this includes the entire territory of Nunavut. This may not be as significant to your site as it is to mine ;))

Ok, that brings the optimized code to

With the index.php hiding somewhere in the background?