简体   繁体   English

WordPress永久链接不起作用-启用htaccess和模块重写

[英]Wordpress permalinks not working - htaccess and module rewrite enabled

I've set permalinks to /%postname%/, and have updated .htaccess in the root directory. 我将永久链接设置为/%postname%/,并在根目录中更新了.htaccess。 The module rewrite is enabled on my machine (localhost). 在我的机器(本地主机)上启用了模块重写。 I can't think of any other reason why it's not working. 我无法想到它不起作用的任何其他原因。 Can anyone help me debug it? 谁能帮我调试它?

Here's the logged error: 这是记录的错误:

127.0.0.1 - - [22/Jan/2014:10:27:57 +0000] "GET /olp/about/ HTTP/1.1" 404 497 "http://localhost/olp/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36"

Edit: 编辑:

.htaccess: 的.htaccess:

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

WP is installed in localhost/olp, and .htaccess is in that same directory. WP安装在localhost / olp中,.htaccess位于该目录中。

Edit: more info. 编辑:更多信息。 In my apache2.conf, I've got: 在我的apache2.conf中,我得到了:

<Directory "/var/www/"> 
Options FollowSymLinks 
AllowOverride All 
Order allow,deny 
Allow from all 
</Directory>

Is this configuration correct? 此配置正确吗?

This is now solved. 现在解决了。

Although in apache.conf, I have AllowOverride All, this wasn't set in /etc/apache2/sites-available/default. 尽管在apache.conf中,我具有AllowOverride All,但未在/ etc / apache2 / sites-available / default中设置。 There it had AllowOverride None. 在那里,它具有AllowOverride None。 So I just changed this, restarted apache and now it works. 因此,我刚刚更改了此设置,重新启动了Apache,现在可以使用了。

You may need to copy the index.php (or you may first try to skip this one) and the .htaccess from /localhost/olp to /localhost/ dir. 您可能需要从/ localhost / olp复制index.php(或者首先尝试跳过此代码)和.htaccess到/ localhost / dir。

This advice is according the docs at: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory 该建议根据以下文档中的文档提供: http//codex.wordpress.org/Giving_WordPress_Its_Own_Directory

Usually it is needed when you install it in /localhost and move it to /localhost/olp. 通常,将其安装在/ localhost中并将其移至/ localhost / olp时需要使用它。 But I'm not experienced in installing WP in a subdirectory. 但是我没有在子目录中安装WP的经验。

Another similar questions are available: 还有另一个类似的问题:

Make sure your .htaccess works! 确保您的.htaccess有效!

And a final tip - as it is a localhost installation, you probably can install it directly in the main document root (then I can help much more). 最后一点-由于它是localhost安装,您可能可以直接在主文档根目录中安装它(然后我可以提供更多帮助)。

尝试清理您的.htaccess文件,然后将永久链接再次保存在wp-admin中,wordpress会将Rewrite添加到.htaccess中,有时会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM