【发布时间】:2014-04-10 17:43:49
【问题描述】:
我想让我的永久链接结构指向 %postname%,但这样做会使每个页面都转到一个 404 页面,在该页面上无法在服务器上找到所请求的 URL。 我正在使用 mac 并使用 mac 的 php 和 apache 运行我自己的开发服务器。我按照本指南启动服务器:http://www.coolestguidesontheplanet.com/downtown/get-apache-mysql-php-and-phpmyadmin-working-osx-109-mavericks
这些是我采取的步骤,但都没有奏效:
- 编辑了我的 htaccess
Options +FollowSymlinksRewriteEngine on
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~wayne/plugin-dev/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~wayne/plugin-dev/index.php [L]
</IfModule>
# END WordPress
通过取消注释确保 /etc/apache2/httpd.conf 的重写引擎已打开
LoadModule rewrite_module libexec/apache2/mod_rewrite.so还确保将
AllowOverride设置为全部。
它会起作用的唯一方法是,如果我使用自定义永久链接结构并输入index.php/%postname%/,但我的所有页面前面都会有一个 index.php,我不希望这样。
【问题讨论】:
-
你做错了
/~wayne/plugin-dev/index.php应该只是/index.php。因为你已经提到了RewriteBase /~wayne/plugin-dev/。您的网址上还存在~字符吗? -
我唯一添加的是
Options +FollowSymlinks和RewriteEngine on其他wordpress 自动生成这些。有一个~,因为这就是我可以使用http://localhost/~username/访问我的服务器文件的方式。我按照上面提供的链接设置灯服务器的说明进行操作。
标签: php wordpress .htaccess permalinks