我在根文件夹和子文件夹中安装了WordPress。我可以访问子域中WordPress站点的主页,但永久链接不起作用 - 错误404.我试图重置永久链接,但它没有帮助。我找不到任何.htaccess文件,所以我自己创建了一个并将其放在子文件夹目录中:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projects/bigsargefitness/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /projects/bigsargefitness/index.php [L]
</IfModule>
这是一个子文件夹WordPress站点的链接:http://ninahortendesigns.com/projects/bigsargefitness/
我已将数据库选项设置为上述方向。
谢谢你的帮助。
你需要看一些东西:
以下是编辑的第一个链接中的代码,以便它可以与您的网站一起使用,但如果您有其他规则,则只应在注释下插入该行。
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(projects) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
如果您有自定义规则,则只插入这些行
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(projects) [NC]
假设您是一名设计师并正在上传您构建的网站示例,则下次将新网站上传到wp1 / projects /子目录时,您只需执行第2步
当无法访问您请求的资源或路径时,会出现错误404。在这种情况下,可能是因为URL重写无法正常工作,因此永久链接请求仍然被定向到请求的路径(例如/ projects / bigsargefitness / your-category / your-post-name)而不是重写的路径(即/projects/bigsargefitness/index.php)。
以下解决方案假设您使用Debian / Ubuntu,否则原则应保持不变。
sudo a2enmod rewrite
/etc/apache2/sites-available/your-site.conf
中编辑/添加以下行来确保允许引擎进入子目录:
<Directory /var/www/projects/bigsargefitness/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
这里的关键是确保该行代表AllowOverride All
而不是AllowOverride None
。sudo service apache2 restart
如果这有帮助,请告诉我。