Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][.htaccess] index.php filtruje incude ..., Problem z przesłaniem $_GET
DREEMus
post
Post #1





Grupa: Zarejestrowani
Postów: 286
Pomógł: 34
Dołączył: 4.09.2008
Skąd: Wrocław

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


.htaccess
Kod
RewriteRule ([^-]+)$ index.php?inc=$1 [L]


index.php
  1. <?php
  2. function dolacz( $plik ) {
  3.      require_once( 'web_' . $plik . '.inc' );
  4.      }
  5. // head i tak dalej
  6. print_r( $_GET );
  7. if( isset( $_GET['inc'] ) ) {
  8.         dolacz( $_GET['inc'] );
  9.         } else {
  10.                 require_once 'web_news.inc';
  11.                 }
  12. // reszta ...
  13. ?>


http://localhost/art -> Array ( [inc] => index.php )
http://localhost/index.php?inc=art -> Array ( [inc] => index.php )
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
DREEMus
post
Post #2





Grupa: Zarejestrowani
Postów: 286
Pomógł: 34
Dołączył: 4.09.2008
Skąd: Wrocław

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


jeszcze nie mam, ale chce mieć ...
np. domena.pl/art/1 -> domena.pl/index.php?inc=art&subinc=1

Kod
RewriteRule ^([a-z]+)/([0-9]+)$ index.php?inc=$1&subinc=$2 [L]
RewriteRule ^([a-z]+)$ index.php?inc=$1 [L]


Działa (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

PS. Dodać też RewriteCond przed RewriteRule (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Kod
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


Ten post edytował DREEMus 15.06.2009, 15:10:53
Go to the top of the page
+Quote Post

Posty w temacie


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: 8.10.2025 - 15:35