.htaccess doesn't work if comment row (# ...) exist - .htaccess

code below doesn't work my .htaccess file. I mean, after this code is applied, I can still index folders in html.
# BEGIN disable folder index
Options All -Indexes
# END disable folder index
however, code below works. I mean, after this code is applied, server gives 403 if I try to index a folder which I know that it exists.
Options All -Indexes
I'm on a shared hosting and have nothing to do with server config. .htaccess is created via notepad++ with encoding setting UTF-8 without BOM. .htaccess permission is set to 0644. there exist no other code in .htaccess.
what does this situation mean? what am I doing wrong?

Ok, looks like my original comment above pushed you into the right direction:
Most likely this is a problem with the line breaks. So that for the
interpreting part of the http server that "Options" line is not on a
separate line, thus also commented out. Check your line ending
characters by using a hexeditor. That s the only reliable tool to do
so.

Related

ownCloud 9 Code Signing and .htaccess

I have a modified .htaccess where I added a RewriteCond.
Now I get on every page load:
There were problems with the code integrity check. More information…
What is the right solution to prevent this error message? And of course, I don't want to use the original .htaccess.
This is easy to fix without having to keep integrity check disabled:
1.) Open up the admin area where you can click Rescan, keep that window open (don't click rescan yet)
2.) Edit your config/config.php file, and add this line to it
'integrity.check.disabled' => true,
3.) Click on Rescan in browser window from step 1 (wait for it to complete)
4.) Change the line added to config/config.php from true to false (or remove the line)
Voila! Profit!
Looks like when you disable integrity check and click the rescan, it will re-generate the signature.json file, and after doing that, you can then re-enable integrity check
:)
I might have found a solution in the documentation, although core developpers say this shouldn't be done:
https://doc.owncloud.org/server/9.0/admin_manual/issues/code_signing.html#errors
You could modify $OWNCLOUDHOME/core/signature.json file in order to update your .htaccess signature.
This should make owncloud think it has the right .htaccess file.
In order to do that:
1) run ./occ integrity:check-core
This will give you the expected signature and the actual signature for your core files.
2) edit core/signature.json and replace, on the .htaccess entry, the provided signature with your htaccess signature (given in step 1).
If, later, you need to file a bug report, owncloud developpers might ask you to restore the original .htaccess file and the original signature.json file, so make a backup. This feature is intended to mildly improve security and facilitate the developpers work.
Hope this will help you !
Edit Owncloud 9.1:
I've updated my own owncloud instance, and though I really do not recommand you to do that (use it at your own risks), you can disable code check in the config.php file.
Just add 'integrity.check.disabled' => true,

How to remove number in any url address in specific folder .htaccess

I want to remove numbers on the end url in specified folder, using htaccess.
(Numbers and minus sign befor numbers). For all urls in this folder.
For example
http://www.example.com/music/new-track-released-52
or
http://www.example.com/music/helo-there-4
Need to look like
http://www.example.com/music/new-track-released
http://www.example.com/music/helo-there
For all links in folder music
(I'm already removed php extension with htaccess)
How to do that?
Probably something like this:
RewriteEngine on
RewriteRule ^/music/(.+)-[0-9]+$ /music/$1
Note that this is the version for the host configuration. For .htaccess style files this has to be slightly modified. Whenever possible you should prefer not to use .htaccess style files but the real host configuration instead. Those files are notoriously error prone, hard to debug and really slow the server down.

No php.ini file

I'm making a PHP form that requests a file for download. I've had an error with the script and did some searching found out that it was because my php.ini file needed allow_url_fopen = On, so I went to change the settings and my site has no php.ini file. I couldn't really find out how to make a php.ini file. How would I create this file? My web host says I need to create it. What are the default settings to put into this file?
First, try to figure out, whether you really don't have the file. The php.ini location can be found in phpinfo(); output.
Second, if there is such file, edit that one. If not, download the ZIP package from php.net and there is at least php.ini.recommended, which contains basic directives.
Well, if you have no php.ini file, you can create it with as few lines in it as you need. Just put allow_url_fopen = On on an ascii file and name it php.ini, copy it to the working directory or the public root. Take in mind that anyway this values can be overrided by hosting's staff in places where you do not have access. To see what is the final and actual setting that aplies use phpinfo().
A side note: .htaccess files can in some circunstances govern and override php settings, so also take a look on all of them (that are accesible to you) to see if you can set your preferences there. Be careful that systax differs from php.ini .htaccess example

Font embedding and .htaccess in Firefox

Check out http://fube.ca in any browser but Firefox and you'll see that the cloud logo is a custom glyph font. In Firefox, though, the font won't load.
As best I can gather, the problem is that I'm serving the font from a subdomain and Firefox has strict requirements about the serving fonts from the exact same domain as the site. Apparently I can get around this by making a change to my .htaccess file, but the recommended changes don't seem to be working. See https://www.fontspring.com/support/troubleshooting/webfonts-are-not-loading-in-firefox and http://enable-cors.org.
Based on what I gather from these, here is what my .htaccess file currently looks like:
AddHandler php-stable .php
Header set Access-Control-Allow-Origin "*"
The first line was already there. I added the second (blank) and third lines. What am I doing wrong?
Actually, it turns out that my changes to .htaccess didn't save somehow. Adding that line to .htaccess does fix the problem.

.htaccess or other URL Case Sensitive

My server is Case Sensitive, and id like to turn it to inSensitive.
Example of what I mean is
lets say I upload Fruit.php
Well then going to this file wont work:
www.website.com/fruit.php
but this one will:
www.website.com/Fruit.php
Is there a way so Fruit.php and fruit.php will work? also with the directories. i.e:
/Script/script.php
/script/Script.php
You need to use the mod_speling (sic) apache module:
http://httpd.apache.org/docs/1.3/mod/mod_speling.html
In .htaccess
<IfModule mod_speling.c>
CheckCaseOnly On
CheckSpelling On
</IfModule>
The CheckSpelling operative makes Apache perform a more involved effort to find a match e.g. correcting common spelling mistakes
Case sensitivity depends on the file system, not Apache. There is a partial solution, however. mod_rewrite can coerce everything to lowercase (or uppercase) like so:
RewriteMap tolowercase int:tolower
RewriteRule ^(.*)$ ${tolowercase:$1}
Reference: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap
Unfortunately, this only works if all your files are lowercase, while you specifies mixed case filenames (Fruit.php.) Are you comfortable renaming all the files in your project lowercase?
UNIX-servers are case-sensitive - they distinguish between upper-case and lowercase letters in file names and folder names. So if you move your website from a windows to a UNIX-server (when you change web host for instance), you risk getting a certain amount of "Page not found"-errors (404 errors), because directories and other websites linking to yours sometimes get the cases wrong (typically writing the first letter of folder names in upper-case etc.). This javascript-based custom 404-error page solves the problem by converting URL's into lowercase.
You can get the script from http://www.forbrugerportalen.dk/sider/404casescript.js
Happy coding !!!!!!!

Resources