Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z RewriteRule
deha21
post 14.12.2017, 21:38:08
Post #1





Grupa: Zarejestrowani
Postów: 544
Pomógł: 5
Dołączył: 18.08.2009

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


Mam problem z przekierowaniami w .htaccess. Słaby jestem w te klocki i nie wiem dlaczego nie działają mi jak powinny.

Mam tak:
RewriteRule ^boosting/([a-zA-Z]+)$ boosting.php?game=$1 [NC,QSA]
RewriteRule ^boosting/([a-zA-Z]+)/([a-zA-Z-]+)$ boosting.php?game=$1&type=$2 [NC,QSA]
RewriteRule ^boosting$ boosting.php [NC,QSA]

Potrzebuję zrobić tak:

strona.pl/boosting -> boosting.php
strona.pl/boosting/XXX -> boosting.php?game=XXX
strona.pl/boosting/XXX/YYY -> boosting.php?game=XXX&type=YYY

Co gorsze, wchodząc na strona.pl/boosting (bez końcowego slasha) wywala błąd 404. A gdy wpiszę boosting/XXX wyrzuca mnie do boosting/XXX/?game=XXX


--------------------
Go to the top of the page
+Quote Post
Tomplus
post 15.12.2017, 10:14:39
Post #2





Grupa: Zarejestrowani
Postów: 1 832
Pomógł: 225
Dołączył: 20.03.2005
Skąd: Będzin

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


Nie wiem w czym proble, ale wszystko działa:

Kod
RewriteRule ^boosting/([a-zA-Z]+)$ boosting.php?game=$1 [L]
RewriteRule ^boosting/([a-zA-Z]+)/([a-zA-Z-]+)$ boosting.php?game=$1&type=$2 [L]
RewriteRule ^boosting$ boosting.php [NC,QSA]


Wynik: http://domena.pl/boosting.php?game=Gra&type=Pokemon

Zauważ że użyłem parametr [L]
Go to the top of the page
+Quote Post
deha21
post 18.12.2017, 17:03:15
Post #3





Grupa: Zarejestrowani
Postów: 544
Pomógł: 5
Dołączył: 18.08.2009

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


Nie działa. Skopiowałem Twój kod i
1. /boosting/ nie działa - wywal błąd 404
2. /boosting/game/ - nie działa - wywala błąd 404
3. /boosting/game/type - tylko to działa


--------------------
Go to the top of the page
+Quote Post
Tomplus
post 18.12.2017, 18:03:58
Post #4





Grupa: Zarejestrowani
Postów: 1 832
Pomógł: 225
Dołączył: 20.03.2005
Skąd: Będzin

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


[APACHE] pobierz, plaintext
  1. RewriteRule ^boosting/$ boosting.php?game=$1 [L]
  2. RewriteRule ^boosting/([a-zA-Z]+)/$ boosting.php?game=$1 [L]
  3. RewriteRule ^boosting/([a-zA-Z]+)/([a-zA-Z-]+)$ boosting.php?game=$1&type=$2 [L]
  4. RewriteRule ^boosting$ boosting.php [NC,QSA]
[APACHE] pobierz, plaintext


To będzie działać.
Polecam do testów używać tej strony:
http://htaccess.mwl.be/
Go to the top of the page
+Quote Post
deha21
post 18.12.2017, 22:26:59
Post #5





Grupa: Zarejestrowani
Postów: 544
Pomógł: 5
Dołączył: 18.08.2009

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


Wygląda na to, że działa! Dzięki biggrin.gif


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 18.04.2024 - 08:11