SuperPuperLesha Posted January 4, 2011 Report Share Posted January 4, 2011 (edited) Добрый день,скажите плиз,как мне с помощью htaccess переадресовать запросы типа http://site/dir1 или http://site/dir2 на http://site/url.phpкроме http://site/ или http://site/index.php?a=bСпасибо... Edited January 4, 2011 by SuperPuperLesha Quote Link to comment Share on other sites More sharing options...
0 ShumNo Posted January 4, 2011 Report Share Posted January 4, 2011 если надо 301 редирект попробуйте такRewriteRule ^dir1$ http://site/url.php [R=301,L] Quote Link to comment Share on other sites More sharing options...
0 SuperPuperLesha Posted January 4, 2011 Author Report Share Posted January 4, 2011 если надо 301 редирект попробуйте такRewriteRule ^dir1$ http://site/url.php [R=301,L]Ок, а параметры можно передать? В http://site/url.php , те которые пришли на адрес http://site/dir1,или сам "dir1" ? Quote Link to comment Share on other sites More sharing options...
0 ShumNo Posted January 4, 2011 Report Share Posted January 4, 2011 (edited) средствами htaccess? вряд ли это вам надо переадресацию делать на phpХотя вы уточните какие параметры подразумеваете Edited January 4, 2011 by ShumNo Quote Link to comment Share on other sites More sharing options...
0 rus Posted January 5, 2011 Report Share Posted January 5, 2011 Redirect или RedirectMatch Quote Link to comment Share on other sites More sharing options...
0 Veseloff Posted January 5, 2011 Report Share Posted January 5, 2011 Мне кажется, что топикстартеру нужен RewriteRule. Что-то типаRewriteRule ^dir\d+$ /url.php [L] Quote Link to comment Share on other sites More sharing options...
0 SuperPuperLesha Posted January 6, 2011 Author Report Share Posted January 6, 2011 Спасибо за наводку, всё получилось. Quote Link to comment Share on other sites More sharing options...
0 BeJIuT Posted January 16, 2011 Report Share Posted January 16, 2011 У меня тоже подобный вопроскак сделать http://www.site.ru/view.php?userlogin=rest112 вhttp://www.rest112.site.ruесть кодRewriteBase /RewriteCond %{HTTP_HOST} !^www\.site\.ru$RewriteCond %{HTTP_HOST} (www\.)?(.*)\.site\.ru$RewriteRule ^(.*)$ view.php?userlogin=%2&$1помогите пожалуйста, заранее спасибо Quote Link to comment Share on other sites More sharing options...
0 Veseloff Posted January 17, 2011 Report Share Posted January 17, 2011 Не очень понятно что именно надо: то ли преобразовывать someuser.site.ru в site.ru/userlogin=someuser, то ли наоборот. Если первый вариант, то вроде всё правильно делаете. У меня вот так работает:RewriteCond %{HTTP_HOST} !^test\.local$RewriteCond %{HTTP_HOST} (.*)\.test\.local$RewriteRule ^(.*)$ index.php?userlogin=%1 Quote Link to comment Share on other sites More sharing options...
0 BeJIuT Posted January 17, 2011 Report Share Posted January 17, 2011 У меня сейчас так http://www.site.ru/view.php?userlogin=rest112, а надо http://www.rest112.site.ru . RewriteBase /RewriteCond %{HTTP_HOST} !^www\.site\.ru$RewriteCond %{HTTP_HOST} (www\.)?(.*)\.site\.ru$RewriteRule ^(.*)$ view.php?userlogin=%2&$1этот код стоит но не работает, выходит страница "Невозможно найти удалённый сервер" а может быть что хостинг не переваривает такие перенаправления. ? Quote Link to comment Share on other sites More sharing options...
0 Veseloff Posted January 17, 2011 Report Share Posted January 17, 2011 Вероятно, просто в DNS не указаны поддомены. Надо, чтобы было* IN A xxx.xxx.xxx.xxxНу и, конечно же, в апаче в конфигах сделатьServerAlias *.site.ruЕсли фронтендом стоит ещё какой-то сервер, то в нём тоже необходимо проверить, чтобы все поддомены были включены. Quote Link to comment Share on other sites More sharing options...
Question
SuperPuperLesha
Добрый день,
скажите плиз,
как мне с помощью htaccess переадресовать запросы типа
http://site/dir1 или http://site/dir2
на http://site/url.php
кроме http://site/ или http://site/index.php?a=b
Спасибо...
Edited by SuperPuperLeshaLink to comment
Share on other sites
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.