admin管理员组文章数量:1125975
Our WordPress site is in a subfolder /subwp/
, and all pages except the home page work. This is the root folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subwp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subwp/index.php [L]
</IfModule>
When visiting the homepage (e.g. /
) I get the hosting providers default site ('this domain is hosted by xyz'). All other slugged pages work perfectly.
Just to make sure that the hosting provider is not somehow auto redirecting requests to /
, I created a file named index.php
with just 'blah' in it, to see if it would work then, and then if I visit , I see the text 'blah' (and also all other pages display blah now :))
I'm kinda stuck. Any ideas?
Our WordPress site is in a subfolder /subwp/
, and all pages except the home page work. This is the root folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subwp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subwp/index.php [L]
</IfModule>
When visiting the homepage (e.g. http://example.com/
) I get the hosting providers default site ('this domain is hosted by xyz'). All other slugged pages work perfectly.
Just to make sure that the hosting provider is not somehow auto redirecting requests to /
, I created a file named index.php
with just 'blah' in it, to see if it would work then, and then if I visit http://example.com
, I see the text 'blah' (and also all other pages display blah now :))
I'm kinda stuck. Any ideas?
Share Improve this question edited Dec 1, 2020 at 16:50 MrWhite 3,8911 gold badge20 silver badges23 bronze badges asked Dec 1, 2020 at 15:51 Marcelnl1Marcelnl1 132 bronze badges 1 |2 Answers
Reset to default 0Because when you request the document root, the rule in .htaccess
does not match and the request is not rewritten to the subdirectory. So the request falls through and whatever is the default response for the document root is served (eg. /index.php
if it exists).
You need to add another directive to rewrite the homepage only.
(The first RewriteRule
directive is not correct either.)
For example:
RewriteEngine On
RewriteBase /subwp/
RewriteRule ^[^/]+/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
# Special case - rewrite requests for the homepage (which is also a directory)
RewriteRule ^$ index.php [L]
Since you are using RewriteBase
you can remove the /subwp/
prefix on the RewriteRule
substitution strings (that's the whole point of using RewriteBase
).
An alternative... This was driving up the wall and the provided solution was not working. Turned out my browser had cached a 301 error with forwarding to the WordPress folder version of the URL. I cleared the cache and my problem was fixed.
本文标签: htaccessSite in subfolderall pages work except home
版权声明:本文标题:htaccess - Site in subfolder - all pages work except home 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736678747a1947316.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
.htaccess
file in the WordPress subdirectory, or are you doing everything from the root.htaccess
file? – MrWhite Commented Dec 1, 2020 at 16:51