Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> RewritRule przekierowanie
Cinamicom
post
Post #1





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Witam.

Na serwerze mam kilka domen, potrzebuję zrobić przekierowanie, z tej jednej wybranej domeny.

z www.mojadomena.pl/index.php?url=$1 na www.mojadomena.pl/index.php?url=w/c/$1

Potrzebuję dodać właśnie tą "w/c"



W moim frameworku mam już jeden taki zapis: "RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]"

Potem ładuje sobie to tak: http://strona.pl/adres/url/jakis

Na jednej domenie właśnie muszę dodać /w/c przez tym adres/url/jakis

Proszę o pomoc i dziękuje.
Go to the top of the page
+Quote Post
2 Stron V   1 2 >  
Start new topic
Odpowiedzi (1 - 19)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Kod
RewriteRule ^(.+)$ index.php?url=/w/c/$1 [QSA,L]
(IMG:style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
Cinamicom
post
Post #3





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Ale potrzebuję dla danej domeny. Wszystkie domeny mam podpięte pod jeden katalog, i potrzebuję właśnie sprecyzowaną domenę w rewrit.
Go to the top of the page
+Quote Post
Pyton_000
post
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Kod
RewriteCond %{HTTP_HOST} ^www.stara-strona.pl [or]
RewriteCond %{HTTP_HOST} ^stara-strona.pl
Go to the top of the page
+Quote Post
Cinamicom
post
Post #5





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Niestety to nie działa:

RewriteCond %{HTTP_HOST} ^www.strona.pl/index.php?url=w/c/$1 [or]
RewriteCond %{HTTP_HOST} ^strona.pl/index.php?url=w/c/$1
Go to the top of the page
+Quote Post
Pyton_000
post
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


To co Ci dałem masz dodać PRZED RewriteRule
RewriteCond - czytaj google
Go to the top of the page
+Quote Post
Cinamicom
post
Post #7





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


No dobra, dałem tak:
RewriteCond %{HTTP_HOST} ^www.stara-strona.pl [or]
RewriteCond %{HTTP_HOST} ^stara-strona.pl

przed rewriit rule i co dalej?


Przepraszam za moje głupie pytanie, ale .htaccess mało razy się bawiłem.
Go to the top of the page
+Quote Post
trueblue
post
Post #8





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


RewriteCond %{HTTP_HOST} ^www.domena.pl [OR]
RewriteCond %{HTTP_HOST} ^domena.pl
RewriteCond %{QUERY_STRING} url=(.*)
RewriteRule .* index.php?url=/w/c/%1 [L]
Go to the top of the page
+Quote Post
Cinamicom
post
Post #9





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Tak, tylko czy to przypadkiem nie przekierowuje na /w/c/$1 wszystkich domen?
Go to the top of the page
+Quote Post
trueblue
post
Post #10





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Tylko domena domena.pl lub www.domena.pl, taki jest warunek w RewriteCond.
Go to the top of the page
+Quote Post
Cinamicom
post
Post #11





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Niestety to nie działa, a teraz nawet public/style.css nie działa (IMG:style_emoticons/default/smile.gif)

  1. Options -Indexes
  2.  
  3. RewriteBase /
  4.  
  5. # General rewrite rules
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. RewriteCond %{REQUEST_FILENAME} !-f
  8. RewriteCond %{REQUEST_FILENAME} !-l
  9.  
  10. RewriteCond %{HTTP_HOST} ^www.dsadas.pl [OR]
  11. RewriteCond %{HTTP_HOST} ^dsadas.pl
  12. RewriteCond %{QUERY_STRING} url=(.*)
  13. RewriteRule .* index.php?url=/w/c/%1 [L]
  14.  
  15.  
  16. RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]


Go to the top of the page
+Quote Post
trueblue
post
Post #12





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Ostatniej regułki nie dodawaj.
Go to the top of the page
+Quote Post
Cinamicom
post
Post #13





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Na domenie nadal nie działa, a na innej domenie wywala "Nie odnaleziono obiektu"

Ale widzę że nawet na tej mojej regułce jak dodam w/c to też nie działa. Dzwine..

Bo teraz muszę wpisywać tak: www.domena.pl/w/c/1argument/2argument/3argument a chcę zrobić właśnie bez tego wpisywania /w/c - kontroler i akcja

Ten post edytował Cinamicom 6.08.2014, 11:49:31
Go to the top of the page
+Quote Post
trueblue
post
Post #14





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Zgubiłem się. Na pewno chcesz przepisać index.php?url=blabla czy /w/c/param1/param2/param3 ?
Go to the top of the page
+Quote Post
Cinamicom
post
Post #15





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Główne przekierowanie jest takie: RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] - no i używam np. strona.pl/w/c/orderbyid/

Dla kilku innych domen będę potrzebował dodać tam w/c/ - i użycie strona2.pl/orderbyid


Cytat(trueblue @ 6.08.2014, 13:09:34 ) *
Zgubiłem się. Na pewno chcesz przepisać index.php?url=blabla czy /w/c/param1/param2/param3 ?

Go to the top of the page
+Quote Post
trueblue
post
Post #16





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


  1. RewriteCond %{HTTP_HOST} ^www.dsadas.pl [OR]
  2. RewriteCond %{HTTP_HOST} ^dsadas.pl
  3. RewriteCond %{REQUEST_URI} ^/(.*)
  4. RewriteRule .* index.php?url=/w/c/%1 [L]
Go to the top of the page
+Quote Post
Cinamicom
post
Post #17





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Dalej nie działa, dziwne, dziwne
Go to the top of the page
+Quote Post
trueblue
post
Post #18





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Skopiuj powyższe i sprawdź na: http://htaccess.madewithlove.be/
Być może ja nie rozumiem jaki efekt chcesz osiągnąć.
Go to the top of the page
+Quote Post
Cinamicom
post
Post #19





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 8.07.2013

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


Masz może gg? Podeślij mi na pw.
Go to the top of the page
+Quote Post
Pyton_000
post
Post #20





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


podaj dokładnie jaki adres ma być przepisany na jaki
Go to the top of the page
+Quote Post

2 Stron V   1 2 >
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: 23.08.2025 - 17:14