到自定义的固定链接不起作用(开箱即用)

时间:2012-07-06 作者:Siddharth

我试图改变的模式。将wordpress文件夹中的htaccess转到644。然而,我明白

Not Found
The requested URL /wordpress/features/ was not found on this server.
我一直在读关于重新安排工作的书。htaccess以使永久链接正常工作。无法理解。

以下是我的详细信息。htaccess

# Comment
DirectoryIndex index.html index.htm index.php
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /wordpress/
        RewriteCond %{QUERY_STRING} (^|\\?|&)s2member_file_download\\=.+
        RewriteRule .* - [E=no-gzip:1]
</IfModule>
# BEGIN FlexiCache Standalone
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST}        localhost$
    RewriteCond %{REQUEST_METHOD}   GET
    RewriteCond %{REQUEST_URI}      !^/wp-
    RewriteCond %{HTTP_COOKIE}      !(wordpress_logged_in|comment_author|wp-postpass)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d [OR]
    RewriteCond %{REQUEST_URI}      ^/$
    RewriteRule ^(.*)               wp-content/plugins/flexicache/standalone.php [L]
</IfModule>
# END FlexiCache Standalone
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_setenvif.c>
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\\.0[678] no-gzip
        BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html
        BrowserMatch \\bMSI[E] !no-gzip !gzip-only-text/html
    </IfModule>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
    </IfModule>
</IfModule>
<FilesMatch "\\.(css|js|htc|CSS|JS|HTC)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag None
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.4"
    </IfModule>
</FilesMatch>
<FilesMatch "\\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=3600, public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag None
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.4"
    </IfModule>
</FilesMatch>
<FilesMatch "\\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag None
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.4"
    </IfModule>
</FilesMatch>
# END W3TC Browser Cache

# BEGIN s2Member GZIP exclusions
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteCond %{QUERY_STRING} (^|\\?|&)s2member_file_download\\=.+
    RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END s2Member GZIP exclusions

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

# END WordPress
# BEGIN Security advice from http://www.problogdesign.com/wordpress/11-best-ways-to-improve-wordpress-security/
# 8 – No Directories Should be Available for Browsing
# By default in most hosting, index of directories are shown in web browsers. This has a purpose but it also means that you reveal the content of any directory that has no index.html or index.php.

# Modifying this behavior is easy with Apache, just add the following line of code to the .htaccess file in the root directory (In the same place as the wp-config.php file).
Options All -Indexes
# END Security advice
编辑:停用所有插件sudo a2enmod rewritesudo /etc/init.d/apache2 restart. 启用永久链接,刷新页面。这个htaccess文件已自动创建。主页显示正常(一如既往),其他页面/链接均不起作用。我在本地主机上试过了。我的网站位于www.mcruiseon。com公司

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

4 个回复
最合适的回答,由SO网友:Damien 整理而成

听起来您的VHOST的Allow Override指令仍然设置为NONE

默认情况下,这是禁用的,因此即使您通过sudo a2enmod rewrite 你的htaccess将被忽略。

您需要登录到服务器(通过终端/外壳),然后。。。

sudo nano /etc/apache2/sites-available/default

在文件中查找:

<Directory /var/www/>
    AllowOverride None
    Options MultiViews FollowSymlinks
    Order allow,deny
    Allow from all
    Header Set Cache-Control no-cache
</Directory>
将AllowOverride更改为ALL

Ctrl+x并保存文件

然后

sudo apache restartsudo /etc/init.d/apache2 restart

另见http://drupal.org/node/134439

请告诉我允许覆盖是否已关闭?

SO网友:Milo

这里有两个不同缓存插件和s2成员的重写规则。您收到的错误意味着WordPress甚至没有处理该请求。我建议您禁用插件,备份htaccess文件,然后将其删除,然后访问永久链接设置页面并保存,以便WordPress重新生成您的重写规则。如果您的htaccess文件存在权限问题,您将在permalinks屏幕上看到一个错误。测试你的永久链接是否正常工作,然后只重新启用你正在使用的插件,这意味着选择一个缓存插件。

SO网友:Alm

听起来你的服务器上没有启用mod\\u重写?

如果您有服务器的shell访问权限,请尝试:sudo a2enmod rewrite 然后sudo /etc/init.d/apache2 restart

SO网友:woony

你试过了吗,把最后一块放在最上面?。

我猜你会在某个地方陷入某种无休止的循环,或者它永远不会达到真正的wordpress重写。

从零开始,只有你的wordpress URL,你可以测试它。让我们知道这是否有效。从那以后继续工作。我一点也不惊讶,它看起来一团糟。

结束

相关推荐

如何使用.htaccess保护媒体目录?

我正在尝试使用保护上载目录。H访问。但当我浏览管理面板中的媒体部分时,我会看到用户/通行证弹出窗口<我的猜测是,WordPress使用fopen 查找文件是否存在。我发现mod\\u重写规则允许fopen 但我不知道如何将这些规则用于基本的HTTP身份验证。非常感谢您的帮助。以下是允许fopen的重写规则:RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^.+$ [NC] RewriteRu