Some tips in the use of “.htaccess”
Caution
This article was published more than a year ago, there may have been developments.
Please take this into account.
Arriving at the third consecutive post its ".htaccess"I think it's appropriate to say that the topic intrigues me enough. Today we will see some tips and customizations in the use of ".htaccess”, improving performance of our server.
Create the page "404 Not Found"
The page "404 Not Found"That Apache is set by default deliberately stripped. To give a touch of professionalism to our site to create a board on the basis of general graphics site, as per the attached sample.

E 'can also create the pages dedicated to other errors. Let's see how:
ErrorDocument 401 /error/401.php
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php
Search Engine Optimization
It may happen that in the course of time a page is deleted the moved. It 's always possible to leave a link that points to the old one to the new one, but it is not always recommended, especially if we want a good indexing. Using ".htaccess"We have the ability to make the redirect so that the search engine does not notice be redirected.
Redirect 301 /d/file.html http://www.htaccesselite.com/r/file.html
Hide the window download
Usually, when we try to save something, incur in the typical Firefox window (when usiamo Firefox) that asks us if we want to save or open the file. To avoid this step just enter in our. "Htaccess" the following lines:
AddType application/octet-stream .pdf AddType application/octet-stream .zip AddType application/octet-stream .mov
Block access to. "Htaccess"
For the safety of the server is always better block unwanted access to file ".htaccess”.
# htaccess to secure <Files .htaccess> order allow,deny deny from all </Files>
The same mechanism applies to any other file residing on the server:
# exclude access to certain files <files default.jpg> order allow,deny deny from all </files>
Disable directory browsing
Even this is an important expedient for the security. To prevent surfers will find yourself the list of files in the current directory, simply add the following lines:
# disable directory browsing Options All -Indexes
Set the default page
It 's always possible to change the default page of the server to a choice. In this case it will be called "about.html”. Let's see how:
# serve alternate default index page DirectoryIndex about.html
Redirect from an old domain
Always wink to the search engines we can make an automatic redirect from an old domain to the new one.
# redirect from old domain to new domain RewriteEngine On RewriteRule ^(.*)$ http://www.yourdomain.com/$1[R = 301, L]
I never tire of repeating that the file ".htaccess"Are very important, but potentially very dangerous. Incorrect configuration could inhibit us access to the server, whereby caution, copie di backup and tests in local.
4 Comments
TheJoe · 5 November 2011 at 7:18 PM
I could be wrong, but if you already use a component that you edit the htaccess.. then you should not touch it.. As you said, I think the problem are those lines of code you posted. Have you tried to disable them?
David · 1 November 2011 at 10:24 PM
Hello and thanks for your reply.
Uso Joomla, I tried to search on formum joomla, but I found nothing and no one would answer the question that I posed, perhaps they do not know how to help me? :S
And it's’ bel large casino. I use the url rewrite with a component that optimizes everything for me seo, but I disabled the voice on your redirect 301.
In .htacess I added these entries:
# mod_rewrite in use
RewriteEngine On
RewriteCond %{HTTP_HOST} ^davidealgeri.com
RewriteRule ^(.*)$ http://www.davidealgeri.com/$1 [R=permanent,The]
and at the end
Redirect permanent /component/content/frontpage.html http://www.davidealgeri.com/blog-di-psicologia.html
It may have been caused by this?
Thanks anyway
TheJoe · 31 October 2011 at 9:05 AM
Hello David, and thanks for the comment.
I looked at your site (davidealgeri.com), but I can not figure out which CMS uses. Cos’è, drupal?
In any case, you should try looking in the documentation of the CMS that uses something that concerns redirects 301, Also look in the forum (if there is one). And it's’ possible that your CMS uses the url rewrite improperly, or that the IP is blacklisted your facebook htaccess.
The possibilities are many. The first thing I would go to look at the documentation.
We point out, however,, that also happens with W3C Validation.
David · 30 October 2011 at 11:38 PM
Hello I am writing you because I read your article, looking for solutions here and there on the internet and I found it very interesting.
If not if you can help, but I try the same.
I made several changes all'htacess and lately I've noticed that when I post my blog articles on fb, even new ones, me says “301 Moved Permanently”.
Can depend on the settings in your dell'htaccess?
Possibly if you want to see the glue! 🙂