Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [mod_rewrite] przekazanie parametrów szukania
Forum PHP.pl > Forum > PHP
Lejto
Mam taki kod szukajki
  1. <form action="search/" method="get">
  2. <input type="text" name="query" class="text" />
  3. <select class="select">
  4. <option value ="all">all</option>
  5. <option value ="avi">avi</option>
  6. <option value ="mp3">mp3</option>
  7. <option value ="mpeg">mpeg</option>
  8. <option value ="mpg">mpg</option>
  9. <option value ="rar">rar</option>
  10. <option value ="wma">wma</option>
  11. <option value ="wmv">wmv</option>
  12. <option value ="zip">zip</option>
  13. <option value ="mkv">mkv</option>
  14. <option value ="3pg">3pg</option>
  15. </select>
  16. <input type="submit" class="submit" value="" />
  17. </form>

w .htaccess mam taką regułę
Kod
RewriteRule ^search/(.*)$ index.php?page=search&query=$1 [L]

przenosi mnie to dobrego pliku ale nie pokazuje fazy która jest w query
var_dump tak wygląda
Kod
array(2) { ["page"]=>  string(6) "search" ["query"]=>  string(0) "" }

jak to naprawić?


Pozdrawiam
PiotrekM
a jak zwrócisz się tak index.php?page=search&query=text to co wypluje var_dump?
Fifi209
Prócz flagi L daj QSA

http://eriz.pcinside.pl/weblog/mod_rewrite...wiazac-208.html
PiotrekM
pokaż cały plik .htaccess
Lejto
Kod
RewriteEngine On
RewriteRule ^index/$ index.php
RewriteRule ^addpliki$ index.php?page=addpliki [L]
RewriteRule ^zaloguj_t$ index.php?page=zaloguj_t [L]
RewriteRule ^join$ index.php?page=join [L]
RewriteRule ^rejestracja_nowy$ index.php?page=rejestracja_nowy [L]
RewriteRule ^login_f$ index.php?page=login_f [L]
RewriteRule ^zaloguj$ index.php?page=zaloguj [L]
RewriteRule ^logout$ index.php?page=logout [L]
RewriteRule ^loginf$ index.php?page=loginf [L]
RewriteRule ^fpass$ index.php?page=fpass [L]
RewriteRule ^delete_links$ index.php?page=delete_links [L]
RewriteRule ^fpassw$ index.php?page=fpassw [L]
RewriteRule ^user/([A-z]+)$ index.php?page=user&user=$1 [L]
RewriteRule ^panel/([A-z]+)$ index.php?page=panel&user=$1 [L]
RewriteRule ^panel/$ index.php?page=panel&user=$1 [L]
RewriteRule ^register$ index.php?page=join [L]
RewriteRule ^add$ index.php?page=add [L]
RewriteRule ^search/(.*)$ index.php?page=search&query=$1 [L] [QSA]
RewriteRule ^plik/([0-9]+)$ index.php?page=plik&id=$1 [L]
RewriteRule ^przypomnienie_hasla$ index.php?page=przypomnienie_hasla [L]
RewriteRule ^fpassw$ index.php?page=fpassw [L]
erix
[APACHE] pobierz, plaintext
  1. RewriteRule ^search/(.*)$ index.php?page=search&query=$1 [L] [QSA]
[APACHE] pobierz, plaintext

:
[APACHE] pobierz, plaintext
  1. RewriteRule ^search$ index.php?page=search [L] [QSA]
[APACHE] pobierz, plaintext
Lejto
nie chodzi, nie przekazuje w ogóle 'query'
erix
Pokaż var_dump dla tablicy $_SERVER (oczywiście po przesłaniu formularza).
Lejto
proszę
Kod
array(36) { ["REDIRECT_STATUS"]=> string(3) "200" ["HTTP_HOST"]=> string(9) "localhost" ["HTTP_USER_AGENT"]=> string(109) "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)" ["HTTP_ACCEPT"]=> string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ["HTTP_ACCEPT_LANGUAGE"]=> string(23) "pl,en-us;q=0.7,en;q=0.3" ["HTTP_ACCEPT_ENCODING"]=> string(12) "gzip,deflate" ["HTTP_ACCEPT_CHARSET"]=> string(30) "ISO-8859-2,utf-8;q=0.7,*;q=0.7" ["HTTP_KEEP_ALIVE"]=> string(3) "300" ["HTTP_CONNECTION"]=> string(10) "keep-alive" ["HTTP_REFERER"]=> string(29) "http://localhost/maylo/maylo/" ["HTTP_COOKIE"]=> string(96) "autologin=fb0ea33bdc695d230dca657dc16cc2ae; autologin_id=6; PHPSESSID=4fu6ph4cm8e64l8f4b5bpgun15" ["PATH"]=> string(579) "C:\Program Files\Common Files\Symbian\Tools;C:\Perl\site\bin;C:\Perl\bin;C:\Program Files\JavaFX\javafx-sdk1.2\bin;C:\Program Files\JavaFX\javafx-sdk1.2\emulator\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Common Files\Teleca Shared;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;c:\Program Files\Java\jdk1.6.0_12\bin;C:\Program Files\Samsung\Samsung PC Studio 3\;C:\Program Files\QT Lite\QTSystem;C:\Program Files\CSL Arm Toolchain\bin;" ["SystemRoot"]=> string(10) "C:\WINDOWS" ["COMSPEC"]=> string(27) "C:\WINDOWS\system32\cmd.exe" ["PATHEXT"]=> string(48) ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH" ["WINDIR"]=> string(10) "C:\WINDOWS" ["SERVER_SIGNATURE"]=> string(0) "" ["SERVER_SOFTWARE"]=> string(30) "Apache/2.2.6 (Win32) PHP/5.2.5" ["SERVER_NAME"]=> string(9) "localhost" ["SERVER_ADDR"]=> string(9) "127.0.0.1" ["SERVER_PORT"]=> string(2) "80" ["REMOTE_ADDR"]=> string(9) "127.0.0.1" ["DOCUMENT_ROOT"]=> string(12) "J:/Serv/www/" ["SERVER_ADMIN"]=> string(19) "webmaster@localhost" ["SCRIPT_FILENAME"]=> string(33) "J:/Serv/www/maylo/maylo/index.php" ["REMOTE_PORT"]=> string(4) "4672" ["REDIRECT_QUERY_STRING"]=> string(11) "page=search" ["REDIRECT_URL"]=> string(20) "/maylo/maylo/search/" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" ["REQUEST_METHOD"]=> string(3) "GET" ["QUERY_STRING"]=> string(11) "page=search" ["REQUEST_URI"]=> string(31) "/maylo/maylo/search/?query=test" ["SCRIPT_NAME"]=> string(22) "/maylo/maylo/index.php" ["PHP_SELF"]=> string(22) "/maylo/maylo/index.php" ["REQUEST_TIME"]=> int(1266816178) }


muszę przekazać wartość z option i input
erix
Ech, dopiero teraz zauważyłem swój błąd...
[APACHE] pobierz, plaintext
  1. RewriteRule ^search$ index.php?page=search [L,QSA]
[APACHE] pobierz, plaintext
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.