Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

How do I fix a redirect in Firefox so that it leads my site to another address but with a slash at the end of it?

This is my redirect in .htaccess:

RewriteCond %{HTTP_HOST} ^test\.mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.mydomain\.com$
RewriteRule ^testword$ "http\:\/\/outsidedomain\.com\/test\.mydomain\.com\/testword\/" [R=301,L]

It works fine in Chrome.

This is what it's suppose to do: should lead to Instead, in Firefox it leads to Notice the lack of forward slash.

It has to have a slash at the end because otherwise the script from doesn't work properly.

UPDATE: I'm using to display a page at my blog so when a user writes it leads to It show's all right in Chrome where the "nyanit" script is loaded only once but in Firefox displaying that "testword" page starts a redirection again so the page doesn't show but only the sript is showing multiple times.

Check it out here. Try both Chrome and Firefox to see what I mean.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is a classic error, your rule only matches paths which literally match /testword. If you want to redirect everything that begins with /testword, remove the $:

RewriteRule ^testword "http\:\/\/outsidedomain\.com\/test\.mydomain\.com\/testword\/" [R=301,L]

If you want to match /testword and /testword/ and nothing else, make the slash optional by adding /?:

RewriteRule ^testword/?$ "http\:\/\/outsidedomain\.com\/test\.mydomain\.com\/testword\/" [R=301,L]

It looks like that opens in your browser. Perhaps you're viewing a cached page in Chromium which is why the redirection is not infinite. The problem is:

  • is redirected to
  • is opened in a <iframe> by
  • With the rewrite rule, is rewritten again... infinite loop.

Suggestion: don't use an Apache redirect for this, but Javascript. If it's detected that the page is in a frame, do not redirect. Put the below JS code on and remove the apache redirection code:

if (parent == self) {
share|improve this answer
Yes, you're solution is correct but there's obviously a problem with Firefox. When I redirect to, Chrome shows the outside website's script correctly on top of the page from my site but Firefox starts an unlimited loop and loads an outside sripts more than once (indefinitely, actually). Is there a way to fix that? Check out the question update, please. – user11320 Dec 31 '11 at 14:04
@rlesko See updated answer. – Lekensteyn Dec 31 '11 at 14:21
Works perfectly. The only problem now is that there is no sound in Chrome but I'm sure that has nothing to do with the redirect. Doesn't matter actually, thanks for your help... – user11320 Dec 31 '11 at 15:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.