If you have WordPress intalled on your domain’s root directory, you cannot access any other directory on yuor server from front end by typing that directory in your url. Reason for that is WordPress htaccess file catches all http requests and maps them to WordPress index.php file for further processing.
Same is the case with most open source CMS such as Joomla, Drupal etc if you have enabled the url rewriting.
In WordPress, you can exclude one or more directories from being rewritten by adding Rewrite Condition before the rewrite rule in the htaccess file.
Open your WordPress .htaccess file:
Find:
RewriteCond %{REQUEST_FILENAME} !-f
Add after:
RewriteCond %{REQUEST_URI} !^/(folder1|folder2).*$
After modification, your default WordPress .htaccess should look like this:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(folder1|folder2).*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Hope that helps.
Cheers!
Question, if I have a WP in my root directory and I have a php script also in my rout directoy that I want to use on that location. How would I need to change this for it to work if that is even a possibitility?
RewriteCond %{REQUEST_URI} !^/(folder1|folder2).*$
So to be more concrete, the script in the root directory’s is script.php. 🙂
I have not found a possibility to have the script work in a sub directory so I am looking and hoping this could help keeping the script working.
The following code should work.
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/script.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./ /index.php [L]
# END WordPress
Hi
tnx guy.
its solved my problem .
No l luck here.
I’ve also tried:
RewriteRule ^foldername – [L,NC]
To just before the line: RewriteEngine On
Then I took that out and tried:
RewriteCond %{REQUEST_URI} !^/(foldername|foldername/.*)$
To just above the line: RewriteRule ^index.php$ – [L]
None of these are working for us. Any more suggestions?
Thanks
RewriteRule ^foldername – [L,NC] (any RewriteRule) will never work before RewriteEngine On
This above mentioned code has worked on every WordPress blog where I tried it.
Now few basic questions:
Are you on Linux? and what’s your folder name that you are trying to exclude, have you added it in the htaccess? That’s an obvious thing but I have to ask this.
Are your blog permalinks opening fine?
thanks. it’s helps