固定链接问题(.htaccess不起作用)

时间:2012-10-10 作者:user1099480

我想使用permalinks,但它们不起作用。每当我使用permanlinks时,像/%postname*/之类的链接都与默认的不同。。。我得到一个404错误。

调用php\\u info可以看到加载的模块包含mod\\u rewrite。

# BEGIN Better WP Security
Options -Indexes

<files .htaccess>
Order allow,deny
Deny from all
</files>

<files readme.html>
Order allow,deny
Deny from all
</files>

<files readme.txt>
Order allow,deny
Deny from all
</files>

<files install.php>
Order allow,deny
Deny from all
</files>

<files wp-config.php>
Order allow,deny
Deny from all
</files>

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteCond %{SCRIPT_FILENAME} !^(.*)wp-includes/ms-files.php
RewriteRule ^wp-includes/[^/]+\\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]

RewriteCond %{REQUEST_METHOD} ^(TRACE|DELETE|TRACK) [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{QUERY_STRING} \\.\\.\\/ [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(bash|git|hg|log|svn|swp|cvs) [NC,OR]
RewriteCond %{QUERY_STRING} etc/passwd [NC,OR]
RewriteCond %{QUERY_STRING} boot\\.ini [NC,OR]
RewriteCond %{QUERY_STRING} ftp\\:  [NC,OR]
RewriteCond %{QUERY_STRING} http\\:  [NC,OR]
RewriteCond %{QUERY_STRING} https\\:  [NC,OR]
RewriteCond %{QUERY_STRING} (\\<|%3C).*script.*(\\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [NC,OR]
RewriteCond %{QUERY_STRING} base64_encode.*\\(.*\\) [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(\\[|\\]|\\(|\\)|<|>|ê|"|;|\\?|\\*|=$).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*("|\'|<|>|\\|{||).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%24&x).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%0|%A|%B|%C|%D|%E|%F|127\\.0).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(request|select|concat|insert|union|declare).* [NC]
RewriteCond %{QUERY_STRING} !^loggedout=true
RewriteCond %{QUERY_STRING} !^action=rp
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in_.*$
RewriteRule ^(.*)$ - [F,L]

</IfModule>
# END Better WP Security

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
每当我更改permalink结构时,都会发生404错误。apache的error\\u日志显示没有与此问题相关的错误。

操作系统是Suse Linux。Apache/2.2.12。

在httpd中。conf有以下相关条目:

# forbid access to the entire filesystem by default
<Directory /srv/www/htdocs>
      Options +FollowSymLinks
      AllowOverride All
      Order deny,allow
      Deny from all
</Directory>

<Directory />
    Options +FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>

# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\\.ht">
    Order allow,deny
    Deny from all
</Files>
有人知道我可以检查什么来运行permalinks吗?我无法找出我错过了什么。

1 个回复
SO网友:Christiaan

您使用的虚拟主机的文档根目录与httpd中的全局文档根目录集不同吗。形态?如果是这样,您将希望为其他位置指定目录规则,以包括AllowOverride。

结束

相关推荐

HTAccess重写与WordPress规则和SSL冲突

这一条让我很困惑——我有下面的htaccess规则来将ssl重定向到非ssl页面。这很好,但我想从这个规则中排除某些wordpress请求-例如,https://mysite.com/info/. 我尝试了以下方法:#rewrite all ssl pages to non-ssl for everything that doesn\'t have /info/ in the request uri RewriteCond %{HTTPS} on RewriteCond %{REQUE