Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [inne]htaccess Rewrite
smiady
post
Post #1





Grupa: Zarejestrowani
Postów: 137
Pomógł: 2
Dołączył: 2.07.2007
Skąd: Ostrzeszów

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


Witam mam takie reguły w htaccess

  1. RewriteEngine On
  2.  
  3. RewriteRule ^([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1
  4. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1
  5. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2
  6. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2
  7. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2&param1=$3
  8. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2&param1=$3


Mam ścieżkę upload/license/dokument.jpg i chce aby ją odpaliło, ale bez nadpisywania jako index.php?page= jaką regułę należy dodać ?
Go to the top of the page
+Quote Post
trueblue
post
Post #2





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

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


Dodaj przed regułami warunek na:
Kod
RewriteCond %{REQUEST_URI} !upload/license/dokument.jpg$

lub na wszystkie obrazki gdziekolwiek:
Kod
RewriteCond %{REQUEST_URI} !^/(.+)\.(jpg|jpeg|gif|png|bmp)$


Ten post edytował trueblue 15.07.2015, 07:49:20


--------------------
Go to the top of the page
+Quote Post
smiady
post
Post #3





Grupa: Zarejestrowani
Postów: 137
Pomógł: 2
Dołączył: 2.07.2007
Skąd: Ostrzeszów

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


Nistety zachowuje się danej tak samo przy obrazkach:

  1. RewriteEngine On
  2.  
  3. ErrorDocument 403 /error.php?code=403
  4. ErrorDocument 404 /error.php?code=404
  5. ErrorDocument 500 /error.php?code=500
  6.  
  7. RewriteCond %{REQUEST_URI} !^/(.+)\.(jpg|jpeg|gif|png|bmp)$
  8.  
  9. RewriteRule ^([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1
  10. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1
  11. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2
  12. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2
  13. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2&param1=$3
  14. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2&param1=$3
Go to the top of the page
+Quote Post
trueblue
post
Post #4





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

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


Mój błąd. Przed każdą regułą taki warunek. Jeśli drugi warunek to wystarczy przed regułą, która dopasowuje się do podanej ścieżki.


--------------------
Go to the top of the page
+Quote Post
smiady
post
Post #5





Grupa: Zarejestrowani
Postów: 137
Pomógł: 2
Dołączył: 2.07.2007
Skąd: Ostrzeszów

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


Mam tak i nie działa

  1. RewriteEngine On
  2.  
  3. ErrorDocument 403 /error.php?code=403
  4. ErrorDocument 404 /error.php?code=404
  5. ErrorDocument 500 /error.php?code=500
  6.  
  7. RewriteRule ^([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1
  8. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1
  9. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2
  10. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2
  11. RewriteCond %{REQUEST_URI} !^/(.+)\.(jpg|jpeg|gif|png|bmp)$
  12. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2&param1=$3
  13. RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2&param1=$3
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%)
-----


Tyle że z tego co widzę Twój htaccess nie powinien łapać obrazków, bo w żadnym regexp nie masz ujętej .
Go to the top of the page
+Quote Post
smiady
post
Post #7





Grupa: Zarejestrowani
Postów: 137
Pomógł: 2
Dołączył: 2.07.2007
Skąd: Ostrzeszów

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


To co mam robić ? Bo nie łapie
Go to the top of the page
+Quote Post
Pyton_000
post
Post #8





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

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


Jak wpiszesz adres:
upload/license/dokument.jpg
to na jaki adres przerzuca?
Go to the top of the page
+Quote Post
smiady
post
Post #9





Grupa: Zarejestrowani
Postów: 137
Pomógł: 2
Dołączył: 2.07.2007
Skąd: Ostrzeszów

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


tworzy geta $page, $subpage $param co z tego idzie odlapa metode $page->$subpage($param) a jak to nie istnieje to idzie na strone error.php tak mam ustawione
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%)
-----


Pyton_000, oczywiście masz rację.

smiady, czy to Twój cały .htaccess? Czy pełny url wygląda mniej więcej tak http://domena.pl/upload/license/dokument.jpg ?


--------------------
Go to the top of the page
+Quote Post
smiady
post
Post #11





Grupa: Zarejestrowani
Postów: 137
Pomógł: 2
Dołączył: 2.07.2007
Skąd: Ostrzeszów

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


tak
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 Aktualny czas: 21.08.2025 - 04:09