ErrorDocument 404 /err404.php
RewriteEngine on
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/
RewriteRule .* - [L,R=404]
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [L,R=404]
ErrorDocument 404 /err404.php
RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [L,R=404]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$ - [L,R=404]
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
ErrorDocument 404 /err404.php
RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
ErrorDocument 404 /err404.php
RewriteEngine on
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/
RewriteRule .* - [L,R=404]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/
RewriteRule .* - [L,R=404]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$ - [L,R=404]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]
ErrorDocument 404 /err404.php
RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
ErrorDocument 404 /err404.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
ErrorDocument 404 /err404.php
RewriteEngine on
<b>RewriteCond %{HTTP_HOST} ^www\mysite.ru [NC]
RewriteRule ^(.*)$ https://mysite.ru [R=301,L]</b>
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
www.
а вся остальная часть строки, например, mysite.ru будет захвачена в переменную %1 RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.mysite\.ru [NC]
RewriteRule ^(.*)$ https://mysite.ru/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
ErrorDocument 404 /err404.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
ErrorDocument 404 /err404.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index|(.*)\.php /$1 [R=301,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
ErrorDocument 404 /error.php
RewriteEngine on
#Редирект с www на без
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
#Убирает слэш в конце
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
# Если index. php, php -> 404
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
HTTP/1.1 404 Not Found
Server: nginx-reuseport/1.13.4
Date: Sun, 25 Apr 2021 17:06:53 GMT
Content-Type: text/html
Content-Length: 936
Connection: keep-alive
Keep-Alive: timeout=30
Vary: Accept-Encoding
X-Powered-By: PHP/5.6.40
ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index / [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
RewriteRule ^index / [R=301,L]
RewriteRule ^index|/$ / [R=301,L]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index / [R=301,L]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index|/$ / [R=301,L]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index / [R=301,L]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
DirectorySlash Off
.RewriteCond %{REQUEST_FILENAME} !-d
ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index / [R=301,L]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
RewriteRule ^index / [R=301,L]
NC
(nocase).RewriteRule ^index / [R=301,L,NC]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php / [R=301,L,NC]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index|\.php - [R=404,L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index / [R=301,L,NC]
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
# 1) C www на без
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# 3) Убирает множественные слэши в середине url
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
# 4) .php -> 404
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index / [R=301,L,NC]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
# Убирает / на конце url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(|.*/)index /$1 [R=301,L,NC]
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
, то конечный файл начинает отображаться. ---> site.ru/9-class/algebra/makarichev/otvet-1 , bertal выдает:HTTP/1.1 200 OK
Server: nginx-reuseport/1.13.4
Date: Fri, 04 Jun 2021 09:46:05 GMT
Content-Type: text/html
Connection: keep-alive
Keep-Alive: timeout=30
Vary: Accept-Encoding
X-Powered-By: PHP/7.3.20
HTTP/1.1 404 Not Found
Server: nginx-reuseport/1.13.4
Date: Fri, 04 Jun 2021 09:49:34 GMT
Content-Type: text/html; charset=iso-8859-1
Content-Length: 433
Connection: keep-alive
Keep-Alive: timeout=30
Vary: Accept-Encoding
RewriteRule ^([^.]+)$ %{REQUEST_URI}.php [L]
все становиться наоборот... ^([^.]+)$
на ^([^.]+[^/])$
чтобы исключить адреса заканчивающиеся на "/". RewriteRule ^([^.]+[^/])$ %{REQUEST_URI}.php [L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)$ /$1.php [L]
ErrorDocument 404 /404.php
RewriteEngine on
# c www на без
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# на главной index.php index -> 301
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(|.*/)index /$1 [R=301,L,NC]
#Убирает множественные слэши в середине url
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ /$1 [R=301,L]
# .php -> 404
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
# Убирает / на конце url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)$ /$1.php [L]
R=301
указывать адрес с https и доменом.ErrorDocument 404 /404.php
RewriteEngine on
# c www на без
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# на главной index.php index -> 301
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(|.*/)index https://site.ru/$1 [R=301,L,NC]
#Убирает множественные слэши в середине url
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
# .php -> 404
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [R=404,L]
# Убирает / на конце url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ https://site.ru/$1 [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)$ /$1.php [L]
DirectorySlash off