php - Redirect to subdirectory only if not only in that subdirectory -
i facing (probably) quite simple problem plain old php application. have website simple directory structure:
www.domain.com /blog /some_subdirectory /some_other_subdirectory
i redirect user /blog directory everytime visits folder/any file in application except except if in /blog directory.
i have come following snippet inside .htaccess file:
redirect 302 / http://www.domain.com/blog
but of course redirect if inside /blog directory, causing infinite loop of redirects deeper /blog directories don't exist.
how can exclude /blog directory redirect statement?
use mod_rewrite instead because can create negative condition:
rewriteengine on rewritecond %{request_uri} !^/blog rewriterule ^(.*)$ /blog/$1 [l,r]
this, of course, changes what's in browser's url address bar. if don't want bar change, remove ,r
flag square brackets.
Comments
Post a Comment