главная / Создание сайтов / Подключаем Mod_rewrite Подключаем Mod_rewriteMod_rewrite - это один из модулей Apache. Он позволяет, например, преобразовывать ссылки из http://www.oursite.com/index.php?page=contacts в ссылки вида http://www.oursite.com/contacts (seo-friendly). Очень часто начинающий веб-разработчик, прописав в .htaccess все инструкции для seo-friendly, сталкивается с тем, что ничего не работает. Дело в том, что по умолчанию модуль mod_rewirite в Apache отключен. Как подключить mod_rewrite?Используемая версия: Apache 2.2.11 (no ssl) Для подключения данного модуля запускаем текстовый редактор, открываем httpd.conf, который хранится в папочке conf, установочной директории Apache, и исправляем там следующие строки: view sourceprint? 1.#LoadModule rewrite_module modules/mod_rewrite.so view sourceprint? 01.<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"> 02.# 03.# Possible values for the Options directive are "None", "All", 04.# or any combination of: 05.# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 06.# 07.# Note that "MultiViews" must be named *explicitly* --- "Options All" 08.# doesn't give it to you. 09.# 10.# The Options directive is both complicated and important. Please see 11.# http://httpd.apache.org/docs/2.2/mod/core.html#options 12.# for more information. 13.# 14.Options Indexes FollowSymLinks 15. 16.# 17.# AllowOverride controls what directives may be placed in .htaccess files. 18.# It can be "All", "None", or any combination of the keywords: 19.# Options FileInfo AuthConfig Limit 20.# 21.AllowOverride None На view sourceprint? 1.LoadModule rewrite_module modules/mod_rewrite.so view sourceprint? 01.<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"> 02.# 03.# Possible values for the Options directive are "None", "All", 04.# or any combination of: 05.# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 06.# 07.# Note that "MultiViews" must be named *explicitly* --- "Options All" 08.# doesn't give it to you. 09.# 10.# The Options directive is both complicated and important. Please see 11.# http://httpd.apache.org/docs/2.2/mod/core.html#options 12.# for more information. 13.# 14.Options All 15. 16.# 17.# AllowOverride controls what directives may be placed in .htaccess files. 18.# It can be "All", "None", or any combination of the keywords: 19.# Options FileInfo AuthConfig Limit 20.# 21.AllowOverride All Далее перезагружаем веб-сервер Apache. И, по идее, все должно работать. Вы спросите, почему я привел такой большой кусок .htaccess, когда изменил всего 2 строки. Дело в том, что в сети очень много примеров подключения mod_rewrite, но по многим из них не до конца понятно, какой кусок кода нуно менять. Дабы исключить это недопонимание, я привел более полный код. В заключении отмечу, что модуль mod_rewrite используется не только для seo-friendly, 301 редиректа, он также используется для запрета хотлинкинга. Источник: liteproblog.ru |
КОНТАКТЫ
г. Екатеринбург info@vismech.ru |
текущее: НОВОСТИ 05.12.2013 - Уход за флэш-накопителем 05.12.2013 - Компьютер самопроизвольно выключается 05.12.2013 - Почему не запускается компьютер? 27.11.2013 - Canon Legria HF R406 - Описание видеокамеры 27.11.2013 - TravelMate P645 новый лэптоп бизнес-класса от Acer |