Forum Moderators: phranque
this is in my wordpress index file to rewrite the urls. there is a section on my website certain directory that i do not want to rewrite. how can i go about this.
Examples:
RewriteCond %{REQUEST_URI} !^/do-not-rewrite-this-subdirectory/
RewriteCond %{REQUEST_URI} !\.do-not-rewrite-this-filetype$
Jim
[edited by: jdMorgan at 11:23 pm (utc) on Oct. 16, 2007]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}!^/directory-in-root/
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
i have an index.php file there that i pass queries to it and when i do it takes me to wordpress stuff
index.php?query=something
Then, be aware that only that directory will be excluded from the RewriteRule, and that any HTTP requests for URL-paths which resolve to any other areas of the filesystem will be subject to the rule.
Jim
You can 'comment-out' lines by preceding them with one or more "#" characters. But the problem here is not with the code, but probably with the requirements not being fully-defined (this is rather elementary code), or perhaps with an unexpected side effect/interaction or a server configuration problem.
Make sure that you have spaces between every "}" and any following "!" character -- Posting on this forum deletes those spaces, unless you take steps to prevent it. The code should look exactly like this (comments added):
RewriteEngine on
RewriteBase /
#
# Skip rewrite for "/directory-in-root/" directory
RewriteCond %{REQUEST_URI} !^/directory-in-root/
# IF the requested URL-path does not resolve to an existing file
RewriteCond %{REQUEST_FILENAME} !-f
# AND IF the requested URL-path does not resolve to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# THEN rewrite any non-index-page (non-blank) URL-path request to the /index.php file
RewriteRule . /index.php [L]
Jim
[edited by: jdMorgan at 10:34 pm (utc) on Oct. 17, 2007]