.htaccess – this is the configuration file of the Apache web server
.htaccess – is an Apache web server configuration file that allows you to control the operation of the web server and site settings using various parameters (directives) without changing the main web server configuration file.
This is the code I use on my server
Web server: Apache + php-fpm
PHP version 7.0
- A correct redirect to https has been made (if you do not have a secure connection, you must replace the link with https)
- There are no duplicates of www and non-www pages
- Redirect uppercase to lowercase
Replace my site when using the code https://seo2me.com/ on your https://your_domain.com/
Do not forget - do not use a standard notebook for editing! For example, I use Notepad++
Options +SymLinksIfOwnerMatch
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]RewriteCond %{HTTP_HOST} ^www.seo2me.com
RewriteRule ^(.*)$ https://seo2me.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.seo2me.com$ [NC]
RewriteRule ^(.*)$ http://seo2me.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://seo2me.com/$1 [R=301,L]# Редирект url на нижний регистр
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]# Редирект для главной (с /index.php на /)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)\.(css|js|jpe?g|gif|png|bmp|tiff|ico|ttf|otf|eot|woff|svg)$ [NC]
RewriteRule .* - [R=404,QSA,L]RewriteCond %{THE_REQUEST} !^/index\.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [QSA,L]
Усі права захищені.