# # Нам не нужны сюжеты и интриги - про всё мы знаем, про всё, чего ни дашь: # ErrorDocument 400 http://example.net ErrorDocument 403 http://example.net ErrorDocument 404 http://example.net # # Правила задаём от корня: # RewriteEngine on RewriteBase / # # Выбрасываем "www." из всех адресов: # RewriteCond %{HTTP_HOST} ^www\.example\.net$ [NC] RewriteRule ^(.*)$ http://example.net/$1 [R=301,L] # # Заменяем "index.php" на просто "/": # RewriteRule ^$ index.php [L] RewriteCond %{THE_REQUEST} ^(.*)index\.php(.*)$ RewriteRule ^index.php$ / [R=301,L] # # У нас будут короткие ссылки: # RewriteRule ^about/$ about.php [L] RewriteRule ^books/$ books.php [L] RewriteRule ^links/$ links.php [L] RewriteCond %{THE_REQUEST} ^(.*)about(.*)$ RewriteRule ^about$ http://example.net/about/ [R=301,L] RewriteCond %{THE_REQUEST} ^(.*)books(.*)$ RewriteRule ^books$ http://example.net/books/ [R=301,L] RewriteCond %{THE_REQUEST} ^(.*)links(.*)$ RewriteRule ^links$ http://example.net/links/ [R=301,L] # # Но не надо пытаться открыть те же страницы напрямую: # RewriteCond %{THE_REQUEST} ^(.*)about\.php(.*)$ RewriteRule ^about.php$ http://example.net/about/ [R=301,L] RewriteCond %{THE_REQUEST} ^(.*)books\.php(.*)$ RewriteRule ^books.php$ http://example.net/books/ [R=301,L] RewriteCond %{THE_REQUEST} ^(.*)links\.php(.*)$ RewriteRule ^links.php$ http://example.net/links/ [R=301,L] # # Старые ссылки мы тоже сохраним: # RewriteCond %{THE_REQUEST} ^(.*)x-files/old/(.*)$ RewriteRule ^x-files/old/(.*)$ http://example.net/x-files/new/$1 [R=301,L] # # Если админы забыли запретить просмотр каталогов - добавим своё правило: # RewriteEngine on RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.*)$ - [F,L]