2012-04-05 11 views
12

Sto cercando di regolare il mio file htacess per saltare la regola di riscrittura se il file o la directory esiste, ma quando il file esiste, cambia l'URL in qualcosa di diverso. Non so perché questo sta accadendo. Ecco il mio file htaccess:RewriteCond per saltare la regola se il file o la directory esiste

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^project/([^/\.]+)/?$ index.php?view=project&project=$1 [L] 
RewriteRule ^for/content/ag index.php?view=opening&section=ag [L] 
RewriteRule ^for/content/bus index.php?view=opening&section=bus [L] 
RewriteRule ^for/content/fcs index.php?view=opening&section=fcs [L] 
RewriteRule ^for/content/market index.php?view=opening&section=market [L] 
RewriteRule ^for/content/trade index.php?view=opening&section=trade [L] 
RewriteRule ^for/content/teched index.php?view=opening&section=teched [L] 
RewriteRule ^for/content/([^/\.]+)/?$ index.php?view=content_area&section=$1 [L] 

La directory/progetto/nti esiste, con un file index.php. Quando viene immesso l'indirizzo mywebsite.com/folder/project/nti, viene modificato in mywebsite.com/folder/project/nti/?view=project & project = nti. Lo sto applicando su un server di test in cui il sito di esempio si trova in una sottocartella, ma una volta implementato, si troverà nella cartella del server Web principale.

Grazie per qualsiasi aiuto!

risposta

25

Rimuovere più [OR] e avere il vostro codice come questo:

# If the request is not for a valid directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
# If the request is not for a valid link 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^project/([^/.]+)/?$ index.php?view=project&project=$1 [L,NC,QSA] 
Problemi correlati