首页 文章

在子文件夹中找不到WordPress永久链接

提问于
浏览
1

我在根文件夹和子文件夹中安装了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/

我已将数据库选项设置为上述方向 .

谢谢你的帮助 .

2 回答

  • 2

    你需要看一些东西:

    根WP站点(WP1)中的

    • .htaccess文件并编辑它以便WP1不确定't catch the URLs and generate 404 errors, I'我不确定该评论是否有帮助,我已经使用this回答类似的问题 .
      子WP站点(WP2)中的
    • .htaccess文件并将其重命名为"htaccess.old"然后登录到您的wp2 / wp-admin,转到"Settings->Permalinks"检查URL结构是否符合要求(当您访问子站时,它没有't usually change) and click 2924076 at the bottom of the page. This will regenerate your .htaccess file within the context of the sub-directory and you shouldn' t得到404错误像this这样的网页

    以下是编辑的第一个链接中的代码,以便它可以与您的网站一起使用,但如果您有其他规则,则只应在注释下插入该行 .

    # 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步

  • 0

    原因

    当无法访问您请求的资源或路径时,会出现错误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>
    

    The key here is to ensure that the line says AllowOverride All instead of AllowOverride None.

    • 最后,重启服务器:
    sudo service apache2 restart
    

    如果这有帮助,请告诉我 .

相关问题