Citat:
With mod_rewrite you either shoot yourself in the foot the first time and never use it again or love it for the rest of your life because of its power.
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
Mislim da uvod govori sve. Nije potrebno reci da spadam u ovu prvu grupu, ali tezim da napravim prelaz.
Naime problem je sledeci:
Zelim izmene tipa:
* http://localhost/mysite/variable/value.html => http://localhost/mysite/index.php?variable=value
* http://localhost/mysite/bad-variable/bad-value.html => http://localhost/mysite/index.php?location="error-page.html"
* http://localhost/mysite/ => http://localhost/mysite/index.php?location="home"
Prva dva uslova mi rade, ali poslednji ne.
To sam odradio otprilike ovako:
Code:
RewriteEngine on
# Force one address for a site running on port 80
# NOT TESTED
#RewriteCond %{HTTP_HOST} !^http://localhost/posv2/ [NC]
#RewriteCond %{HTTP_HOST} !^$
#RewriteRule ^/(.*) http://localhost/posv2/$1 [R]
# Home page - ovaj deo NE radi
RewriteCond %{HTTP_HOST} !^http://localhost/posv2/ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://localhost/posv2/index.php?location=home [R]
# All valid pages - ovaj deo radi
RewriteRule (.*)\/(.*)\.html$ index.php?$1=$2 [L,NC]
# All invalid pages - ovaj deo radi
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?location="$1" [L,QSA]
RewriteEngine on
# Force one address for a site running on port 80
# NOT TESTED
#RewriteCond %{HTTP_HOST} !^http://localhost/posv2/ [NC]
#RewriteCond %{HTTP_HOST} !^$
#RewriteRule ^/(.*) http://localhost/posv2/$1 [R]
# Home page - ovaj deo NE radi
RewriteCond %{HTTP_HOST} !^http://localhost/posv2/ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://localhost/posv2/index.php?location=home [R]
# All valid pages - ovaj deo radi
RewriteRule (.*)\/(.*)\.html$ index.php?$1=$2 [L,NC]
# All invalid pages - ovaj deo radi
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?location="$1" [L,QSA]
Problem je sto mi deo za home page ne radi kako treba. Izbaci mi "ponekad" tacnu vrednost za location=home, ali mi svi .css i slike odu u aut.
Neznam da li je uopste, bilo sta u .htaccess fajlu dobro, pa se nadam da ce mi neko strucniji ukazati na propuste. Hvala
[Ovu poruku je menjao maddog_srb dana 18.10.2009. u 19:52 GMT+1]