• Home
  • Get help
  • Ask a question
Last post 6 hours 23 min ago
Posts last week 94
Average response time last week 34 min
All time posts 67874
All time tickets 10492
All time avg. posts per day 20

Helpdesk is open from Monday through Friday CET

Please create an (free) account to post any question in the support area.
Please check the development versions area. Look at the changelog, maybe your specific problem has been resolved already!
All tickets are private and they cannot be viewed by anyone. We have made public only a few tickets that we found helpful, after removing private information from them.

#1452 – 404 for files

Posted in ‘sh404SEF’
This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Friday, 27 November 2015 09:52 UTC
wdburgdorf
Hello,

on one site I get different 404 messages for different kinds of requests. Please see these two links:

http://xxxx.ch/nopagelikethis - very nice.

http://xxxx.ch/nofilelikethis.whatever - ugly.

Why is it that any link with an extension leads to an ugly error page instead of the styled sh404sef error page?

Thank you!

Regards,
Ralf.
Friday, 27 November 2015 10:01 UTC
wb_weeblr
Hi

That's because your .htaccess file says so. The 404 message you see is the standard Apache server error message. Meaning that the request never reaches Joomla or sh404SEF, it's directly stopped by the web server.

This has to do with your .htaccess file, and how the rules are setup there, you probably only allow extensions such as html, json,xml or similar but not others.

Rgds
 
Friday, 27 November 2015 12:43 UTC
wdburgdorf
Hi,

if it was only about allowing extensions, then

http://xxxx.ch/.../logo.png

should not work either, because http://xxxx.ch/.../logoXXX.png doesn't.

I do have some exploit protection in .htaccess. But if I remove all of that and only leave the standard SEF part in, it makes no difference.

This is it:

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section


Can you see a problem there?

Regards, Ralf.
Friday, 27 November 2015 12:53 UTC
wdburgdorf
I now added filetypes to the filetype condition line:
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw|png|jpg|gif))$ [NC]

This works for the additional filetypes.

And eventually I changed it to
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(.*))$ [NC]

This should allow all filetypes. I'm not sure if this cannot cause problems elsewhere. Security or other. Would you know?

Thanks, Ralf.
Friday, 27 November 2015 12:58 UTC
wb_weeblr
Hi

if it was only about allowing extensions, then



http://xxxx.ch/.../logo.png



should not work either, because http://xxxx.ch/.../logoXXX.png doesn't
No, this doesn't apply to png or other similar files, because they are physical files on the disk and the rules do not apply to them because of this line:
# and the requested path and file doesn't directly match a physical file

RewriteCond %{REQUEST_FILENAME} !-f
which is why you don't have to include css, js, lng, jpg,... etc file extensions to the rules.

If http://xxxx.ch/.../logo.png (please, only use real, full examples, I cannot check anything without the complete link), is not working then it's simply because the file doesn't exist or the URL is wrong.

ok, so from the start we were talking about a png file?

Rgds

 
Saturday, 28 November 2015 10:57 UTC
wdburgdorf
Hi,

This is the complete link to a file that always worked, because it exists:
http://xxxx.ch/templates/joostrap/images/logo.png

The other one was a random example of a non-existing png.
So RewriteCond %{REQUEST_FILENAME} !-f seems to apply only to files that actually exist?

We were not just talking about png, it was just an example. It really doesn't matter what the extension is. But now that I found that I can add any extension to RewriteCond %{REQUEST_URI} ..., I believe the issue is solved. Unless I got something wrong and this is not the right way to do it.

Thank you!

Regards, Ralf.
Monday, 30 November 2015 14:01 UTC
wb_weeblr
Hi

So RewriteCond %{REQUEST_FILENAME} !-f seems to apply only to files that actually exist?
It doesn't "apply". The purpose of this instruction is to check whether a file exist or not. It is a condition for the rewriting rule to be applied that the file does not exist.

We were not just talking about png, it was just an example. It really doesn't matter what the extension is.
It totally matters. You absolutely do NOT want 404s on images (png, jpg, gif, maybe svg) or css or javascript files to be rewritten and sent to Joomla to display a complete 404 error.

That would mean a full rendering of the page and this will cause a large load on your server for absolutely no reason (there will nobody to look at that page, requests for images are made by programs).

Rgds
 
Monday, 30 November 2015 15:20 UTC
wdburgdorf
Thank you! Even though you might have slightly misunderstood my last comment, your answer to it made the situation totally clear. I directly copied your answer into the answer for my client, this should settle the issue.

Regards,
Ralf.
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.