Prikaz jedne poruke
Stara 8.9.2016, 15:15   #4
Remedy
Veteran
 
Član od: 5.11.2005.
Poruke: 826
Zahvalnice: 177
Zahvaljeno 199 puta na 154 poruka
Određen forumom Re: .htaccess problem

Citat:
dbaja kaže: Pregled poruke
RewriteRule ^kontakt\.php\?lang\=(sr|en)$ /index.php?lang=$1#CONTACT [NE,R]
Ne mozes ovako da pises RewriteRule, jer se ono odnosi samo na deo do pocetka query stringa.
Citat:
Apache mod rewrite dokumentacija kaže:
The Pattern is a regular expression. It is initially (for the first rewrite rule or until a substitution occurs) matched against the URL-path of the incoming request (the part after the hostname but before any question mark indicating the beginning of a query string) or, in per-directory context, against the request's path relative to the directory for which the rule is defined.
Dakle ako hoces da match-ujes query string, moras da koristis:
Kod:
RewriteCond %{QUERY_STRING}
Druga bitna stvar ovde je:
Citat:
By default, the query string is passed through unchanged.
Znaci, ako koristis samo:
Kod:
RewriteRule ^kontakt\.php$ /index.php#CONTACT [NE,R=301]
kontakt.php -> index.php#CONTACT
kontakt.php?lang=sr -> index.php?lang=sr#CONTACT
kontakt.php?lang=en -> index.php?lang=en#CONTACT
kontakt.php?lang=en&foo=bar -> index.php?lang=en&foo=bar#CONTACT

NE (no escape) flag ti treba zbog "#" karaktera.

Poslednja ispravka: Remedy (8.9.2016 u 15:25)
Remedy je offline   Odgovor sa citatom ove poruke