Are you looking for the default .htaccess for popular CMS platforms like WordPress, Joomla, Drupal, or the Laravel framework? You can copy the default .htaccess code provided on this page.
If you already have an .htaccess file in your folder, it is recommended to rename it, for example to .htaccess.old, and then create a new .htaccess file filled with the default htaccess content found on this page.
List of Default .htaccess for Popular CMS
Before proceeding to the list of default .htaccess files, please note that comments or comment are not included in the htaccess file.
If you want to use a default htaccess file that includes comments, it is recommended to get it from the official CMS or framework provider website. For example https://wordpress.org/documentation/article/htaccess/ for the default WordPress .htaccess file.
Default .htaccess for WordPress
Add this .htaccess code to the main folder of your WordPress installation. For example, if you are using the domain namaweb.site on hosting, and WordPress can be accessed via https://namaweb.site, then this .htaccess file can be added to the public_html
RewriteEngine OnRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]RewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]Default .htaccess for WordPress Multisite – Subfolder
RewriteEngine OnRewriteBase /RewriteRule ^index.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^ - [L]RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]RewriteRule . index.php [L]Default .htaccess for WordPress Multisite – Subdomain
RewriteEngine OnRewriteBase /RewriteRule ^index.php$ - [L]
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^ - [L]RewriteRule ^(wp-(content|admin|includes).*) $1 [L]RewriteRule ^(.*.php)$ $1 [L]RewriteRule . index.php [L]Default .htaccess for Laravel
For Laravel, you need to add two .htaccess files. One in the main installation folder (public_html), and the other inside the public folder (public_html/public).
For the .htaccess in the main installation folder, you can use this code
<IfModule mod_rewrite.c>Options +FollowSymLinksRewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/$1 RewriteRule ^(/)?$ public/index.php [L] </IfModule>Next, add this .htaccess inside the public folder
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule>
RewriteEngine On
RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]</IfModule>Alternative .htaccess for Laravel
If your Laravel website is installed in a subfolder, for example wpgan.com/laravel, and the previous default .htaccess does not work, you can use the following .htaccess in your Laravel installation folder
<IfModule mod_rewrite.c><IfModule mod_negotiation.c> Options -MultiViews</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]RewriteCond %{REQUEST_FILENAME} -fRewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ server.php</IfModule>Default .htaccess for CodeIgniter
Just like the default WordPress .htaccess, add this CodeIgniter .htaccess to the main installation folder of your website.
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php/$1 [L]Default .htaccess for Joomla
Options +FollowSymLinks RewriteEngine On RewriteCond %{QUERY_STRING} base64_encode[^(]*([^)]*) [OR] RewriteCond %{QUERY_STRING} (<|<)([^s]*s)+cript.*(>|>) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2}) RewriteRule .* index.php [F]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_URI} !^/index.php RewriteCond %{REQUEST_URI} /component/|(/[^.]*|.(php|html?|feed|pdf|vcf|raw))$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L]Default .htaccess for Sitepad
<IfModule mod_rewrite.c>RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . index.php [L]</IfModule>Default .htaccess to Force HTTPS
This .htaccess can be used on almost any CMS or framework and serves to redirect the website to https when accessed using http.
Add the following code to the very last line of your default .htaccess file
RewriteCond %{HTTPS} offRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]Default .htaccess for Magento
DirectoryIndex index.php php_value memory_limit 512M php_value max_execution_time 18000 php_flag magic_quotes_gpc off php_flag session.auto_start off php_flag suhosin.session.cryptua off php_flag zend.ze1_compatibility_mode Off SecFilterEngine Off SecFilterScanPOST Off SSLOptions StdEnvVars Options +FollowSymLinks RewriteEngine on RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_URI} !^/(media|skin|js)/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule .* index.php [L] AddDefaultCharset Off ExpiresDefault "access plus 1 year" Order allow,deny Allow from all.htaccess to Force WWW
This .htaccess is used to automatically redirect access using www. If you use this, make sure www on your domain can be accessed and points to the same server.
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,QSA,L]Those are some default .htaccess files used for several popular CMS platforms that you can use if you have lost the default .htaccess file on a website you have created.
COMMENTS
Loading...