Closed Bug 450490 Opened 16 years ago Closed 12 years ago

Look into inconsistencies with redirects

Categories

(www.mozilla.org :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: davidwboswell, Unassigned)

References

Details

I've been running into strange behavior with redirects.  It looks like there are some directory level configurations that make redirects behave differently in different locations.  For instance:

Redirect permanent /quality/index.html http://quality.mozilla.org

This doesn't redirect the following URL

http://www.mozilla.org/quality/

But...

Redirect permanent /products/index.html http://www.mozilla.org/projects/

This does redirect the following URL

http://www.mozilla.org/products/

If I try to redirect an index.html page without explicitly referencing index.html though I'm also seeing behavior I don't want.  For instance:

Redirect permanent /quality/ http://quality.mozilla.org

Does redirect 

http://www.mozilla.org/quality/

But it also redirects other pages and creates 404 errors, such as

http://www.mozilla.org/quality/browser/front-end/

Redirecting to the following non-existent page

http://quality.mozilla.org/browser/front-end/

Maybe I just don't fully understand .htaccess configuration options, but I'd like a standard way to redirect a top-level page that doesn't redirect a bunch of other stuff (or that redirects the other pages to the same location).
mod_alias's Redirect directives are somewhat simplistic, and will behave differently from within <Location> <Directory> or .htaccess.

Plus, it only looks at the URI, not the file-path of a file, so that's why using /index.html is almost never what's wanted.

If the objective is to _only_ redirect a single URI from one place to another, mod_rewrite is much better suited. i.e.

RewriteRule ^/quality/$ http://quality.mozilla.org? [R]

Will do what you are trying to do:

Adding '?' at the end of a redirect url instructs mod_rewrite to kill the query string
[R] makes the rewrite into an external redirect.

Keep in mind that mod_rewrite also behaves a little differently when used inside .htaccess files, as URL it sees become relative to the directory containing the .htaccess file. So in the example above, if the .htaccess file was in the quality/ directory, you'd end up with

RewriteRule ^/$ http://quality.mozilla.org/? [R]

Hope this helps

I fixed the rewrite on http://www.mozilla.org/quality/ yesterday.
Thanks for the information.  This is helpful, but I'm still confused about why
the same type of redirect works differently in .htaccess files when redirecting
pages in different parts of the site.

What I'd like to be able to do is redirect an index.html page somehow and have
it work for all URLs that point to that page.  For instance:

Redirect permanent /products/index.html http://www.mozilla.org/projects/

Works for:
http://www.mozilla.org/products
http://www.mozilla.org/products/
http://www.mozilla.org/products/index.html

But this rewrite rule for quality

RewriteRule ^quality[/]?$ http://quality.mozilla.org/ [R]

Works for just:
http://www.mozilla.org/quality
http://www.mozilla.org/quality/

If you go to the quality/index.html page a 404 error comes up, but that's a
legitimate URL for that same page.  What do we have to do to get the quality
pages redirecting the same way as the products pages?
(In reply to comment #3)
> If you go to the quality/index.html page a 404 error comes up, but that's a
> legitimate URL for that same page.  What do we have to do to get the quality
> pages redirecting the same way as the products pages?

Fixed.

RewriteRule ^quality(?:/(?:index.html)?)?$ http://quality.mozilla.org/ [R]
OS: Mac OS X → All
Hardware: Macintosh → All
Reed, thanks for tweaking that quality redirect.  I'd still like to figure out why these redirects are not working consistently.  Finding the answer could save us the effort of going back and converting every redirect for an index.html file to the format in comment #4.
Reed, can you keep any rewrite-engine rules out of the root .htaccess?
I've run into another inconsistency with redirects.  I recently archived the build directory and copied the redirects from /build/.htaccess to /.htaccess but they're working differently now.

The old redirect is still in place on the archive site and you can see that

http://www-archive.mozilla.org/build
http://www-archive.mozilla.org/build/
http://www-archive.mozilla.org/build/index.html

all redirect to

http://developer.mozilla.org/en/Build_Documentation

Now though

http://www.mozilla.org/build/index.html

is the only thing to redirect and you get 404 errors at

http://www.mozilla.org/build
http://www.mozilla.org/build/

The redirect statement is exactly the same though in both .htaccess files:

Redirect permanent /build/index.html http://developer.mozilla.org/en/docs/Build_Documentation

Does anyone have any time to look into what's going on with redirects?  Having this strange behavior is making it difficult to deal with the archiving process.
More strange redirect behavior in bug 408380 and bug 481877.
I just tried the url's and they work fine for me now.  It seems that since you've added the Rewrite for /build, the Redirect probably isn't necessary.  I removed it from my test version and all three URL's redirected for mine correctly.



http://www.mozilla.org/build
http://www.mozilla.org/build/
Depends on: 450328
Closing old Mozilla.org website bugs due to them not being relevant to the new Python-based Bedrock system. Re-open if this is a critical bug and should be resolved on the new system too.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
How about we call this FIXED instead Chris?
Resolution: WONTFIX → FIXED
Component: www.mozilla.org → General
Product: Websites → www.mozilla.org
You need to log in before you can comment on or make changes to this bug.