Rate this article :
3.5/5 | 12 opinion
This article was useful to you ?
Yes
No
Vous avez noté 0 étoile(s)
Sommaire
Procédure
Welcome to our guide to using .htaccess with the LWS Panel. This guide will help you understand and implement the features of .htaccess. We'll show you how to create an .htaccess file, configure a time zone, manage redirects, and much more. Follow the step-by-step instructions to get the most out of your LWS-hosted website.
An .htaccess (Hypertext Access) file is a configuration file used by Apache-based web servers. It allows site developers and administrators to modify the server configuration parameters for the directory in which the .htaccess file is placed, as well as for all sub-directories.
The interest and usefulness of an .htaccess file lies in its ability to control various aspects of the web server without having to modify the main server configuration. This makes the .htaccess file particularly useful in a shared hosting environment, where access to the main server configuration may not be available.
The .htaccess file can be used for a number of tasks, including:
In short, an .htaccess file is a powerful tool for managing and controlling your website on an Apache server. It offers great flexibility and allows in-depth customisation of the way the server manages your site.
Create a text file on your computer using a standard text editor (Notepad, for example). Save the file as .htaccess.
AuthConfig : Authorisation directives (AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, etc.).
Indexes : Directives controlling directory indexing (AddDescription, AddIcon, AddIconByEncoding, AddIconByType, DefaultIcon, DirectoryIndex, FancyIndexing, HeaderName, IndexIgnore, IndexOptions, ReadmeName, etc.).
Limit: Directives controlling host access (Allow, Deny and Order).
FileInfo: Directives controlling document types (DefaultType, ErrorDocument, ForceType, LanguagePriority, SetHandler, SetInputFilter, SetOutputFilter, and mod_mime Add and Remove directives, etc. ), document meta data (Header, RequestHeader, SetEnvIf, SetEnvIfNoCase, BrowserMatch, CookieExpires, CookieDomain, CookieStyle, CookieTracking, CookieName), mod_rewrite directives (RewriteEngine, RewriteOptions, RewriteBase, RewriteCond, RewriteRule) and and Action for mod_actions.
The "Options" directive is disabled: If this parameter is present in your .htaccess file, it will produce an error. We therefore invite you to comment out all lines starting with this directive ( Add a "#" at the beginning of the line. )
However, the "+FollowSymLinks" option in the "Options" directive is active. This feature is used in many CMS such as Joomla. You can therefore comment out the line associated with this parameter in the .htaccess file without worrying.
Creating a custom error page
ErrorDocument 401 /error/401.php ErrorDocument 403 /error/403.php ErrorDocument 404 /error/404.php ErrorDocument 500 /error/500.php
How to configure the time zone on your server
SetEnv TZ Europe/Paris
Blocking IP addresses
allow from all deny from 1.1.1.1.1 deny from 1.1.1.1.1
Permanent redirects
Redirect 301 /mapage.html http://www.monsite.com/manouvellepage.html
Domain redirections
RewriteCond %{HTTP_HOST} ^www.mon-site.com [NC] RewriteRule ^(.*)$ http://www.mon-site.fr/$1 [QSA,R=301]
Server administrator email
ServerSignature EMail SetEnv SERVER_ADMIN monadresse@monsite.com
Protect your images
Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www.)?monsite.com/ [nc] RewriteRule .*.(gif|jpg|png)$ http://www.monsite.com/images/images-de-substitution.jpg [nc]
Make an entire site unavailable for maintenance
RewriteEngine on RewriteRule maintenance.html - [L] RewriteCond %{REMOTE_ADDR} !1.1.1.1.1 RewriteRule .* /maintenance.html [L]
Prevent directory listing
Options All -Indexes
Default page
DirectoryIndex contact.html
Protect your directories and files
# Protect a file AuthType Basic AuthName "Restricted access" AuthUserFile /home/path/.htpasswd Require valid-user # Protect a directory AuthType Basic AuthName "Restricted access" AuthUserFile /home/path/.htpasswd AuthGroupFile /dev/null Require valid-user
Hide or display php errors
php_flag display_errors off
Rate this article :
3.5/5 | 12 opinion
This article was useful to you ?
Yes
No
0mn reading
How to configure SMTP on a CMS
0mn reading
Your contact form doesn't work and no email is received?
1mn reading
How do I create an htaccess file to rewrite a URL?
0mn reading
How do I update Wordpress to the latest version?