我有一个在 Ubuntu Server 14.04 上的 Lamp Server 上运行的 Wordpress 网站。 我只是尝试使用
Post Name
永久链接选项,现在我的页面不再加载。
我打开了Apache服务器的
mod_rewrite
功能,重启了,还是不行。
另外,这是我的
.htaccess
文件:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
注意
/wordpress
文件夹的内容已经直接放入/html
里面了
假设我的网站名称是 mywebsite.com
。
我怎样才能让它发挥作用?
编辑:这是我的
/etc/apache2/sites-available/000-default.conf
文件
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我找到了解决办法。太开心了!
简而言之,我的解决方法是进入 WordPress 管理仪表板,转到:
“设置”>“固定链接”>“常用设置”,并将单选按钮设置为“自定义结构”
,然后粘贴到文本框中:
/index.php/%year%/%monthnum%/%day%/%postname%/
,然后单击“保存”按钮
对于那些运行 apache 2.4 且未找到“默认”的用户,请查看 /etc/apache2/apache2.conf 并进行编辑
目录
允许覆盖全部
目录
目录 /var/www/>
允许覆盖全部
目录
您是否启用了 .htaccess 的使用(如此处所述)? https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles
RewriteRule ^(.*)$index.php?_REQUEST=$1 [L]
它对我有用。
我知道这是一篇旧帖子,但我遇到了同样的问题,并且在任何地方都找不到正确的答案。这不是 .htaccess 文件或文件夹结构权限的问题。问题是将 WordPress 站点移出默认文档根文件夹。
如果您的文档根文件夹的子文件夹中有多个 WordPress 站点或单个站点,则必须为 apache2.conf 或 httpd.conf 文件中的每个子文件夹“放宽对内容的访问”。
添加此功能后,您将能够使用“漂亮的永久链接”,而不是几乎漂亮或普通的永久链接。
/etc/apache2/apache2.conf
/etc/httpd/conf/httpd.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Added
<Directory /var/www/html/site1/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/site2/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>