[英]Wordpress / htaccess / Mod_rewrite - need help linking to non-wordpress script
I've got a wordpress installation in the root folder of a site, and it's working just fine.我在站点的根文件夹中安装了 wordpress,它工作得很好。 I also want to add a completely seperate file - call it
whatever.php
- to the web root as well.我还想在 web 根目录中添加一个完全独立的文件 - 将其命名为
whatever.php
。 It has nothing to do with wordpress, but the way the htaccess file is setup, it's trying to convert the link to a post page that doesn't exist.它与 wordpress 无关,但 htaccess 文件的设置方式,它试图将链接转换为不存在的帖子页面。
How can i write an exception in the htaccess file that will let me link to my whatever.php script, while keeping everything else working as a default?如何在 htaccess 文件中编写一个异常,让我链接到我的whatever.php 脚本,同时保持其他所有内容作为默认值工作?
If you are using the generic htaccess file (above), you shouldn't have any problem, since the line RewriteCond %{REQUEST_FILENAME} !-f
set the condition that the request url ( %{REQUEST_FILENAME}
) is not a file ( !-f
) on the rewrite rule.如果您使用的是通用 htaccess 文件(如上),则应该没有任何问题,因为
RewriteCond %{REQUEST_FILENAME} !-f
行设置了请求 url ( %{REQUEST_FILENAME}
) 不是文件 ( !-f
) 关于重写规则。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
If you are using the auto generated file, you can add that condition to the chain rule definition.如果您使用的是自动生成的文件,则可以将该条件添加到链式规则定义中。
More info:更多信息:
http://codex.wordpress.org/Using_Permalinks http://codex.wordpress.org/Using_Permalinks
http://httpd.apache.org/docs/current/mod/mod_rewrite.html http://httpd.apache.org/docs/current/mod/mod_rewrite.html
This should do it这应该这样做
RewriteEngine on
RewriteRule ^whatever$ whatever.php [QSA,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.