我设置了我的Web服务器,已经创建了一个.htaccess文件和'www'的子目录,其中我将WordPress安装放置。
运行安装后,除了主页外,所有内容似乎都在重定向,因为主页丢弃了404错误,因为.htaccess文件中包含的重定向规则正在添加/www/www/to url。p>猜测这可能很简单,但需要一些客观的帮助。
显然,我的实际域已被替换为'domain.com'
# Turn off indexing of files and directories.
Options -Indexes
# Turn on rewrites.
RewriteEngine on
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Only apply to URLs that aren't already in the subdirectory.
RewriteCond %{REQUEST_URI} !^/www/
# Rewrite all those to insert the subdirectory name.
RewriteRule ^(.*)$ /www/$1
# Redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ www/ [L,R=301]
事实证明,这是一个简单的修复,就像我首先想到的那样。
使用[L]
在最终规则中替换[L,R=301]
,可以通过添加子目录来防止主页回到本身。