Domanda

Ho il seguente URL di riscrittura:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs 
RewriteRule ^(.*)$ index.php?page=$1 [PT,L]

Ora voglio aggiungere un'eccezione, che se l'URL è qualcosa come mysite.com/abc dovrebbe ignorarlo e tutte le cose al suo interno. Anche mysite.com/abc/dfgs dovrebbe essere escluso da questa riscrittura.

Come posso farlo?

È stato utile?

Soluzione

Se / abc è una directory esistente, puoi inserire un altro file .htaccess con

RewriteEngine Off  

Se è davvero solo una stringa che non vuoi riscrivere (che esista o meno)

RewriteCond %{REQUEST_URI} !^/abc  

non riscriverà se il percorso richiesto inizia con " / abc "

Per testare le regole di riscrittura senza incasinare il sito per i normali browser (non che dovresti modificare in un ambiente live ovviamente, questo è puramente ipotetico :-)), ho trovato molto utile quanto segue:

RewriteCond %{REMOTE_ADDR} 12.34.56.78 # <-- where that's your IP address  

Altri suggerimenti

Questo dovrebbe evitare di riscrivere se l'URI contiene abc. Questo può o non può essere esattamente quello che vuoi. In caso contrario, modifica la tua domanda.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Rewrite ONLY if the REQUEST does NOT contain abc
RewriteCond %{REQUEST_URI} !abc

# Rewrite all other URLs 
RewriteRule ^(.*)$ index.php?page=$1 [PT,L]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top