Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> mod_rewrite - pętla przekierowań
RAM
post
Post #1





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 7.10.2008

Ostrzeżenie: (0%)
-----


Dzień dobry,
Mam dwie domeny x.com.pl i y.com.pl. Chciałbym żeby przez przeglądarkę WWW można było wejść tylko na x.com.pl, np. http://www.x.com.pl a domenę y.com.pl zostawić tylko na adres e-mail, np. biuro@y.com.pl.

W pliku .htacess mam:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.html [L]

RewriteCond %{HTTP_HOST} ^www.y.com.pl$ [OR]
RewriteCond %{HTTP_HOST} ^y.com.pl$
RewriteRule /not_found.html -
RewriteRule .* http://www.y.com.pl/not_found.html [L]

Problem w tym, że mam pętlę przekierowań.
Jak ją usunąć?

Spróbowałem więc tak:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.html [L]

RewriteCond %{HTTP_HOST} ^www.y.com.pl$
RewriteCond %{REQUEST_URI} !^not_found.html$
RewriteRule .* http://www.y.com.pl/not_found.html [L]

ale to też tworzy pętle, nie wiem dlaczego.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
devnul
post
Post #2





Grupa: Zarejestrowani
Postów: 1 470
Pomógł: 75
Dołączył: 21.09.2005
Skąd: że znowu

Ostrzeżenie: (0%)
-----


spróbuj tak
Kod
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.y.com.pl$ [NC,OR]
RewriteCond %{HTTP_HOST} ^y.com.pl$ [NC]
RewriteRule ^(.*)$ not_found.html [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.html [L]

powinno działać
Go to the top of the page
+Quote Post
RAM
post
Post #3





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 7.10.2008

Ostrzeżenie: (0%)
-----


Działa dobrze. Dziękuję bardzo.

A da się tak zrobić żeby zamiast pliku not_found.html był błąd HTTP 404?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 19:36