Rate this article :
This article was useful to you ?
Yes
No
Vous avez noté 0 étoile(s)
Sommaire
Procédure
The .htaccess file is a configuration file that controls how the web server responds to various requests. It is supported by many web servers, including the popular Apache web server used by most commercial web hosting providers.
.htaccess files operate at directory level, allowing them to override global configuration settings in .htaccess directives higher up in the directory tree.
In this tutorial, you will learn how to create and use an .htaccess file.
In theory, every folder (directory) on your cPanel hosting could have an .htaccess file. As a general rule, there is one at the root of your hosting, the folder: public_html
To create an .htaccess file in your cPanel hosting:
Here are some .htaccess directives you could use:
Redirect one page of your site to another :
Redirect 301 /oldpage.php http://www.domaine.com/nouvellepage.php
Redirect an entire site to a new URL:
Redirect 301 / http://www.domaine.com/
Redirect an entire site to a sub-folder, useful for redirecting the main site of your cPanel (published in "public_html") to the folder of an additional domain:
Redirect 301 / http://www.domaine.com/dossier/
Redirect a subfolder to another URL:
Redirect 301 /subfolder http://www.domaine.com/
This directive will redirect any file with the .html extension to use the same filename but use the .php extension instead.
RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php
Redirect the old domain to the new one
RewriteEngine on RewriteBase / RewriteRule (.*) http://www.nouveaudomaine.com/$1 [R=301,L]
Redirect to www.
RewriteEngine on RewriteBase / rewritecond %{http_host} ^domaine.com [nc] rewriterule ^(.*)$ http://www.domaine.com/$1 [r=301,nc]
Redirect to the www. version in a subfolder
RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} domaine.com [NC] RewriteRule ^(.*)$ http://www.domaine.com/dossier/index.html [R=301,NC]
Redirect the old site to the new one, preserving the links :
Options +FollowSymLinks RewriteEngine On RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC]
Redirect the old domain contained in a folder to the new one, with or without a directory, preserving the links:
Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} ^/folder/(.*)$ RewriteRule ^(.*) http://www.nouveaudomaine.com/%1 [R=302,NC]
Redirect URLs with parameters (files placed in the root folder)
Example Original URL :
http://www.example.com/index.php?id=1
Desired URL :
http://www.example.com/nouvel-emplacement/
The .htaccess syntax :
RewriteEngine on RewriteCond %{QUERY_STRING} id=1 RewriteRule ^index\.php$ /new-location/? [L,R=301]
Redirect URLs with parameters (files placed in a subfolder)
Original URL :
http://www.example.com/sub-dir/index.php?id=1
Desired URL :
http://www.example.com/path-to-new-location/
The .htaccess syntax :
RewriteEngine on RewriteCond %{QUERY_STRING} id=1 RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]
Redirect the root of your website to the "public" folder, useful for the Symfony and Laravel frameworks:
RewriteEngine on RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L]
You have learned how to create and use your htaccess file in your cPanel hosting. The .htaccess file can be used to perform SEO-related tasks such as redirects. Redirects can be used to avoid 404 error messages and to let search engine spiders know which pages to index.
Don't hesitate to share your comments and questions!
You can discover other .htaccess directives on the following pages:
Rate this article :
This article was useful to you ?
Yes
No
1mn reading
How do I change my package to cPanel hosting?
1mn reading
Wordpress Cpanel: lost administration login
0mn reading
How do you migrate your website from LWS Panel to cPanel?
0mn reading
How to migrate from cPanel hosting to a VPS server
Bonjour,
Merci pour votre retour.
Afin de pouvoir retrouver l'adresse de votre serveur SQL, l'idéal est de se rendre dans votre espace client LWS puis dans MySQL & phpMyAdmin, ici, vous devriez avoir la possibilité de créer une base de données ce qui entrainera un envoi de mail automatique avec un mot de passe et les informations de connexion à cette dernière. Vous pouvez également suivre cette documentation qui devrait vous renseigner d'avantages.
L'information du serveur est également affichée dans la liste des bases de données sous la colonne "IP Serveur"
Dans le cas où vous auriez une formule de type cPanel, une documentation est aussi mise à dispositions si vous le souhaitez. Il suffira d'utiliser l'adresse IP du serveur indiqué dans la partie droite de votre cPanel, elle est indiquée sous Shared IP Address.
Je vous remercie pour votre attention et reste à votre disposition pour toutes autres demandes ou interrogations complémentaires à propos de nos services. Vous pouvez nous contacter directement depuis votre espace client ou par le biais de cette page.
Cordialement, L'équipe LWS.