开发者

How to modify .htaccess to expose file at specific location on site already hosting wordpress installation?

I agreed to host a file for an online community, but I've since changed my site around so that it's now hosting a wordpress blog. What I'd like is to not break the existing URL to this one file, so, for example, when people navigate to the URL where file is being hosted, e.g. myblog.com/path/to/file, I'd like Apache to handle the URL rather than Wordpress, so that the file on the filesystem is delivered, rather than a Wordpress "We could not find the post" page. I t开发者_开发技巧hink that the way to do this is to modify .htaccess so that that specific URL myblog.com/path/to/file does not execute index.php. Right now, here's what my .htaccess file looks like:

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

# END WordPress

Could anyone tell me how to modify .htaccess to unmanage the URL to one file, but execute index.php for all other URLs?

Any guidance would be appreciated. Thanks.


These rules

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

will tell mod_rewrite to skip any file or directory which actually exist. As long as you don't move this special file of yours, then mod_rewrite won't redirect the rewrite to the main index.php.

Now, if you're moving the file elsewhere, but want to preserve the old url, then you'll have to do as toscho said in his answer do a Redirect.


Redirect permanent /old/path/to/file /new/path/to/file
# BEGIN WordPress ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜