.htaccess RewriteCond%{REQUEST_FILENAME}!-d不起作用

时间:2013-04-14 03:11:12

标签: wordpress .htaccess permalinks

我想在子目录中安装WordPress并在永久链接中删除index.php。 服务器是IIS 6.0,支持重写。 我的网络服务器有以下目录:

  

根目录
  --wp [wordpress文件夹]

根目录/ htaccess的

RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteRule ^(/)?$ wp/

根目录/ WP / htaccess的

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f #1
RewriteCond %{REQUEST_FILENAME} !-d #2
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] #3

当我访问 a.luckyet.com a.luckyet.com/hello-world.html 时,它会有效 但是当我访问 a.luckyet.com/wp-login.php a.luckyet.com/wp-admin

时它不起作用

#3工作正常,但#1和#2无法正常工作。然后我看到here并将 webroot / wp / .htaccess 的内容更改为:

RewriteEngine on 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

它仍然没有生效。谁能帮我?提前谢谢!

更新

ISAPI_Rewrite版本是3.0。

webroot / .htaccess 中的所有代码:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteRule ^(/)?$ wp/

webroot / wp / .htaccess 中的所有代码:

RewriteEngine on 
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule wp-(.*) wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f #1
RewriteCond %{REQUEST_FILENAME} !-d #2
RewriteRule (.*) index.php/$1 [L]

Wordpress永久链接是:

/%postname%.html

因此,Wordpress可以在访问http://a.luckyet.com/http://a.luckyet.com/hello-world.html

时正常工作

问题:

如果 webroot / wp / 中存在类似a.html的真实文件,例如 webroot / wp / a.html ,则会在访问时报告wordpress 404错误 http://a.luckyet.com/a.html ,.我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您正在使用.htaccess文件和WordPress设置动态重写URL以加强.html扩展名 - 任何“真实”.html文件的文件都由IIS处理程序映射在上游处理。

您必须在IIS中更新.html文件中的处理程序映射,尤其是将请求直接定向到物理文件。

相关问题