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.
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.
精彩评论