如何使.htaccess在根目录安装了wordpress的子文件夹中工作


How to make .htaccess work in subfolders with wordpress installed at root

我的服务器由 Hostgator 托管,其中包含多个域,如下所示

在根上,我的主站点已安装,并且我有名为web_sites现在安装其他域的位置,问题是当我尝试访问我的子文件夹时,例如它 http://www.xyz.com/subfolder/工作,但是当我尝试访问类似的东西时 http://www.xyz.com/subfolder/category/furniture现在子文件夹也有.htaccess文件,所以它显示我找不到页面 http://www.xyz.com

那是因为根 .htaccess 没有使内部 .htacess 文件工作,有什么解决方案这是我的 .htaccess 文件

                # BEGIN WordPress
                <IfModule mod_rewrite.c>
                 RewriteEngine On
                 RewriteBase /
                 RewriteCond %{REQUEST_FILENAME} !-f
                 RewriteCond %{REQUEST_FILENAME} !-d
                 RewriteRule . /index.php [L]
                 </IfModule>
                  # END WordPress

这是子文件夹中的 .htacess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^home/$ index.php [L,QSA]
RewriteRule ^search_result/$ search_result.php [L,QSA]
RewriteRule ^pages/([-A-z0-9]+)/? pages.php?url=$1 [L,QSA]
RewriteRule ^user/([-A-z0-9]+)/? author.php?username=$1 [L,QSA]
RewriteRule ^cms/([-A-z0-9]+)/? cms.php?url=$1 [QSA,L]
RewriteRule ^location_posts/([-A-z0-9]+)/? city.php?city=$1 [L,QSA]
RewriteRule ^topcat/([-A-z0-9]+)/([-A-z0-9]+)/? categories.php?id=$1&name=$2 [L,QSA]
RewriteRule ^maincat/([-A-z0-9]+)/([-A-z0-9]+)/? main_categories.php?id=$1&name=$2 [L,QSA]
RewriteRule ^posts/([-A-z0-9]+)/([-A-z0-9]+)/? post_description.php?id=$1&name=$2 [L,QSA]
RewriteRule ^special/([-A-z0-9]+)/? special_detial.php?url=$1 [L,QSA]
RewriteRule ^specials_products/$ specials_products.php [L,QSA]
RewriteRule ^pricing/$ printing_pricing.php [L,QSA]
RewriteRule ^custom_design/$ custom_design.php [L,QSA]
RewriteRule ^registration/$ registeration.php [L,QSA]
RewriteRule ^portfolio/$ portfolio.php [L,QSA]
RewriteRule ^custom_quote/$ custom_quote.php [L,QSA]
RewriteRule ^templates/$ templates.php [L,QSA]
RewriteRule ^all_templates/$ download_templates.php [L,QSA]
RewriteRule ^recent_posts/$ recent_posts.php [L,QSA]
RewriteRule ^current_auctions/$ current_auctions.php [L,QSA]
RewriteRule ^anil_lal/$ info.php [L,QSA]

附言我试图通过搜索来找到我的解决方案 没有一个是有效的.

在根 .htaccess 中为您的子目录添加明确的豁免,例如

RewriteCond %{REQUEST_FILENAME} !^subfolder

应该是:

RewriteCond %{REQUEST_FILENAME} !-d 

我终于找到了一个解决方案,它确实有效,但它并不令人满意,所以我正在发布它,以便它可能会有所帮助 ppl

我所做的是从Wordpress的管理面板转到

设置 ->永久链接

将永久链接更改为默认

因此,它将把您的WordPress网站显示为 http://xyz.com/?p=123

但是您的子文件夹网站具有漂亮的URL可以工作

请继续关注,直到我找到其他解决方案