Bug #17009

default .htaccess file does not rewrite correctly

Added by Lukas Rueegg over 8 years ago. Updated over 4 years ago.

Status:Resolved Start date:2007-02-19
Priority:Should have Due date:
Assigned To:Michael Stucki % Done:

0%

Category:Communication Spent time: -
Target version:-
TYPO3 Version:4.1 Is Regression:
PHP Version:4 Sprint Focus:
Complexity:

Description

the following line in the default .htaccess file doesn't rewrite correctly on the files 'showpic.php' and 'favicon.ico' because of the implicit '/' at the end of the line:

RewriteRule ^(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php|favicon\.ico)/ - [L]

it should be corrected by either adding a '?' after the slash to make the slash optional or by separating calls to directories and files on two different rewrite rules.

if making a GET request to /favicon.ico, the file is still redirected to index.php because it doesn't match the rewrite rule which requires a trailing slash.
(issue imported from #M5020)


Related issues

related to Core - Bug #23173: Code for rewrite rules for .htaccess cannot be formatted ... Closed 2010-07-14
related to Core - Bug #23799: Add IfModule mod_rewrite.c to misc/advanced.htaccess Closed 2010-10-20

History

#2 Updated by Michael Stucki over 6 years ago

This is partly fixed now: The template for the packages (dummy.tar.gz) contains a fixed _.htaccess file. What remains to be done is that misc/advanced.htaccess in TYPO3core gets fixed as well.

However, most users will never notice this because they have copied the file to their website root manually. Should we try to notify them, and if so, how?

#4 Updated by Christian Kuhn over 6 years ago

Maybe fixing misc/advanced.htaccess and an additional little entry in NEWS.txt is be enough?

#5 Updated by Michael Stucki over 6 years ago

Sure, it's the least we can do. However, even though I know it, I would probably not notice that one of my sites has still the old rules file...

#6 Updated by Michael Stucki over 6 years ago

Anyway, don't worry too much about this. At least it will work for all new sites.

#7 Updated by Michiel Roos about 6 years ago

Here is another idea:

http://typofree.org/article/archive/2008/june/title/rethinking-the-mod-rewrite-rules-yes-again/

I have been using this on all my sites for a while now, with success.

#8 Updated by Michiel Roos about 5 years ago

Please bear with me, it's not that hard.

Rule 1:
- Never rewrite 'static' resources. That would be silly right? If a certain request exists as an actual file on the filesystem: serve the file.

Rule 2
- Rewrite everything else.

Rule 3
- wrap the rewrite stuff with an <ifModule > to avoid 500 errors.

Ship with this .htaccess enabled by default.

-------------------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On

  1. Do not rewrite static resources
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -l
    RewriteRule .* - [L]
  1. Rewrite the rest to index.php
    RewriteRule .* /index.php [L]
    </IfModule>
    -------------------------------------------------------------------------------------------

#9 Updated by Chris topher over 4 years ago

That one is fixed: The ending slash was fixed with #23173, IfModule mod_rewrite.c was added in #23173.

Resolved.

Also available in: Atom PDF