Страница не найдена с htaccess .htm для перенаправления .html - PullRequest
0 голосов
/ 27 августа 2018

Используя CouchCMS, я включил симпатичный URL, чтобы сделать все расширения .php и .php? P = 12 до .html.CouchCMS самостоятельно генерирует собственную запись htaccess, чтобы выполнить перенаправление.Все работает хорошо, и вот текущий htaccess с добавлением одной строки кода в начале для перенаправления .htm на .html

Но он не работает для других страниц, которые являются стандартными и не имеют ничего общего с CMS.example.com/contact.html, после ввода example.com/contact.htm я получаю страницу, не найденную.

где я делаю неправильно?

Options +SymLinksIfOwnerMatch -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On

#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it RewriteBase /subdomain1/subdomain2
RewriteBase /

#If you wish to use a custom 404 page, place a file named 404.php in your website's root and uncomment the line below.
#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it ErrorDocument 404 /subdomain1/subdomain2/404.php
#ErrorDocument 404 /404.php

#If your site begins with 'www', uncomment the following two lines
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^(.*)\.htm$ $1.html [R=permanent]

#DO NOT EDIT BELOW THIS

RewriteRule ^index.php$ $1.html [R=301,L,QSA]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

#slots.php
RewriteRule ^slots$ "$0/" [R=301,L,QSA]
RewriteRule ^slots/$ slots.php [L,QSA]
RewriteRule ^slots/.*?([^\.\/]*)\.html$ slots.php?pname=$1 [L,QSA]
RewriteRule ^slots/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ slots.php?d=$1$2$3 [L,QSA]
RewriteRule ^slots/[^\.]*?([^/\.]*)/$ slots.php?fname=$1 [L,QSA]
RewriteRule ^slots/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#root.php
RewriteRule ^root$ "$0/" [R=301,L,QSA]
RewriteRule ^root/$ root.php [L,QSA]
RewriteRule ^root/.*?([^\.\/]*)\.html$ root.php?pname=$1 [L,QSA]
RewriteRule ^root/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ root.php?d=$1$2$3 [L,QSA]
RewriteRule ^root/[^\.]*?([^/\.]*)/$ root.php?fname=$1 [L,QSA]
RewriteRule ^root/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#news.php
RewriteRule ^news$ "$0/" [R=301,L,QSA]
RewriteRule ^news/$ news.php [L,QSA]
RewriteRule ^news/.*?([^\.\/]*)\.html$ news.php?pname=$1 [L,QSA]
RewriteRule ^news/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ news.php?d=$1$2$3 [L,QSA]
RewriteRule ^news/[^\.]*?([^/\.]*)/$ news.php?fname=$1 [L,QSA]
RewriteRule ^news/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#globals.php
RewriteRule ^globals$ "$0/" [R=301,L,QSA]
RewriteRule ^globals/$ globals.php [L,QSA]
RewriteRule ^globals/.*?([^\.\/]*)\.html$ globals.php?pname=$1 [L,QSA]
RewriteRule ^globals/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ globals.php?d=$1$2$3 [L,QSA]
RewriteRule ^globals/[^\.]*?([^/\.]*)/$ globals.php?fname=$1 [L,QSA]
RewriteRule ^globals/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#freeplaygame.php
RewriteRule ^freeplaygame$ "$0/" [R=301,L,QSA]
RewriteRule ^freeplaygame/$ freeplaygame.php [L,QSA]
RewriteRule ^freeplaygame/.*?([^\.\/]*)\.html$ freeplaygame.php?pname=$1 [L,QSA]
RewriteRule ^freeplaygame/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ freeplaygame.php?d=$1$2$3 [L,QSA]
RewriteRule ^freeplaygame/[^\.]*?([^/\.]*)/$ freeplaygame.php?fname=$1 [L,QSA]
RewriteRule ^freeplaygame/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#download.php
RewriteRule ^download$ "$0/" [R=301,L,QSA]
RewriteRule ^download/$ download.php [L,QSA]
RewriteRule ^download/.*?([^\.\/]*)\.html$ download.php?pname=$1 [L,QSA]
RewriteRule ^download/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ download.php?d=$1$2$3 [L,QSA]
RewriteRule ^download/[^\.]*?([^/\.]*)/$ download.php?fname=$1 [L,QSA]
RewriteRule ^download/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#casino.php
RewriteRule ^casino$ "$0/" [R=301,L,QSA]
RewriteRule ^casino/$ casino.php [L,QSA]
RewriteRule ^casino/.*?([^\.\/]*)\.html$ casino.php?pname=$1 [L,QSA]
RewriteRule ^casino/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ casino.php?d=$1$2$3 [L,QSA]
RewriteRule ^casino/[^\.]*?([^/\.]*)/$ casino.php?fname=$1 [L,QSA]
RewriteRule ^casino/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#articles.php
RewriteRule ^articles$ "$0/" [R=301,L,QSA]
RewriteRule ^articles/$ articles.php [L,QSA]
RewriteRule ^articles/.*?([^\.\/]*)\.html$ articles.php?pname=$1 [L,QSA]
RewriteRule ^articles/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ articles.php?d=$1$2$3 [L,QSA]
RewriteRule ^articles/[^\.]*?([^/\.]*)/$ articles.php?fname=$1 [L,QSA]
RewriteRule ^articles/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#index.php
RewriteRule ^.*?([^\.\/]*)\.html$ ?pname=$1 [L,QSA]
RewriteRule ^([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ ?d=$1$2$3 [L,QSA]
RewriteRule ^[^\.]*?([^/\.]*)/$ ?fname=$1 [L,QSA]
RewriteRule ^\w[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]
</IfModule>
...