Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML] .htaccess - Reguły rewrite
d0m1n1k_
post
Post #1





Grupa: Zarejestrowani
Postów: 208
Pomógł: 3
Dołączył: 13.07.2009
Skąd: Tarnów

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


Witam,
staram się napisać zasady rewrite do prostego przetworzenia adresu
http:// www.domena.pl/results/index.php?searchelement=<ciąg_alfanumeryczny>
http:// www.domena.pl/results/index.php?searchelement=<ciąg_alfanumeryczny>&ct<1_do_9>=<Y_lub_N>
na
http:// www.domena.pl/results/<ciag_alfanumeryczny>/
http:// www.domena.pl/results/<ciag_alfanumeryczny>/ct<1_do_9>/<Y_lub_N>

Przygotowałem następujący plik .htaccess

  1. Options FollowSymLinks
  2. RewriteEngine On
  3. DirectoryIndex index.php
  4. RewriteBase /results/
  5. RewriteCond %{REQUEST_FILENAME} !-f
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. RewriteRule ^/(.+)/([a-zA-Z0-9]+)/$ index.php?searchelement=$2


Niestety nie działa :-/
Gdzie popełniłem błąd?

Z góry dziękuję za pomoc.

Ten post edytował d0m1n1k_ 20.10.2015, 20:01:28
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%)
-----


Kod
RewriteRule (.+)/([a-zA-Z0-9]+)/$ index.php?searchelement=$2


A jeszcze lepiej:
Kod
RewriteCond %{REQUEST_URI} ^/(.+)/([a-zA-Z0-9]+)/$
RewriteRule .* index.php?searchelement=%2


Drugie przepisanie podobnie.

Ten post edytował trueblue 20.10.2015, 20:05:10
Go to the top of the page
+Quote Post
d0m1n1k_
post
Post #3





Grupa: Zarejestrowani
Postów: 208
Pomógł: 3
Dołączył: 13.07.2009
Skąd: Tarnów

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


Zmieniłem na:
  1. Options FollowSymLinks
  2. RewriteEngine On
  3. DirectoryIndex index.php
  4. RewriteBase /~0015-newaoi/results/
  5. RewriteCond %{REQUEST_FILENAME} !-f
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. RewriteCond %{REQUEST_URI} ^/(.+)/([a-zA-Z0-9]+)/$
  8. RewriteRule .* index.php?searchelement=%2


Po wpisaniu http:// www.domena.pl/results/W128A550/ wyskakuje:

BŁĄD 500
Wystąpił wewnętrzny błąd serwera. Prosimy później spróbować ponownie.
WebServ 2.1 (Apache/2.2.22 (Win32) PHP/5.3.20 MySQL 5.5.21)

Element Loaded Modules mod_rewrite jest włączony.
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%)
-----


Na początek wyrzuć RewriteBase
Go to the top of the page
+Quote Post
d0m1n1k_
post
Post #5





Grupa: Zarejestrowani
Postów: 208
Pomógł: 3
Dołączył: 13.07.2009
Skąd: Tarnów

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


Działa.
Ale teraz wywaliło mi całą stronę...

Ten post edytował d0m1n1k_ 20.10.2015, 22:17:02
Go to the top of the page
+Quote Post
trueblue
post
Post #6





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

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


W jakim sensie wywaliło?
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: 26.08.2025 - 08:58