views:

128

answers:

1

I'm using Wordpress and have the following pemalink /%category%/%postname%. This gives me user friendly URLs like http://www.example.com/something/.

With this permalink, I will not be able to access php files directly, e.g. http://www.example.com/something/myfile.php.

I need to write a ReWrite rule which allows me access to /include/myfile.php. Can some help me please? :)

Here's my current .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myblogdirectory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myblogdirectory/index.php [L]
</IfModule>
# END WordPress

Update

Ok, I got it working.

I was doing it wrong from the start. I was using the "virtual" path instead of the physical path.

Instead of /mysite/includes/myfile.php, I have to use /wp-content/themes/mytheme/include/myfile.php

I could probably also have added RewriteCond %{REQUEST_URI} !myfile.php, which would have excluded myfile.php from the rewrite rules. I have not tested this though.

+1  A: 

Well, your rewrite rules looks good.

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

means that /blog/index.php won't be serverd if %{REQUEST_FILENAME] is a physical file or directory.

More info here.

Are you sure that you're using the correct file paths?

The file you want to request should be located in /blog/include/myfile.php.

Check your error.log for apache for any related messages.

alexn
But doesn't it say that "The base for these rules are for /myblogdirectory/". If a whatever.php file is requested, foward request to /myblogdirectory/index.php" ? (I've updated the code to.)
Steven
PS. This is a good article about understanding Wordpress Permalinks: http://www.homebizpal.com/blogging/wordpress/understanding-wordpress-permalinks/
Steven