Htaccess - Rewrite правила - как убрать .html в конце адреса браузера
Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2023
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Htaccess - Rewrite правила - как убрать .html в конце адреса браузера
Рабочий код Rewrite правил для того чтобы убрать .html в конце адреса сайта:
RewriteEngine on RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.html\ HTTP RewriteRule ^([^.]+)\.html$ http://your_site.ru/$1 [R=301,L] RewriteCond %{REQUEST_URI} !(\.[^./]+)$ RewriteCond %{REQUEST_fileNAME} !-d RewriteCond %{REQUEST_fileNAME} !-f RewriteRule (.*) /$1.html [L]
Проверка:
http://your_site.ru/services.html редиректит на http://your_site.ru/services