即使使用 htaccess 文件,子页面也无法在 Kirby 中工作
Subpages aren't working in Kirby even with htaccess file
我正在尝试使用 MAMP 在本地设置 Kirby。我有我的 MAMP 设置,所以我可以将 运行 多个站点作为虚拟主机。我使用此代码:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Users/oscargodson/Dropbox/projects/icarus"
ServerName dev.icarus
</VirtualHost>
当我转到 dev.icarus 时,初始页面加载完全正常。所有 CSS,图像,一切。一旦我尝试转到子页面,包括面板,我得到 404。我确定 htaccess 文件在文件夹中。我尝试使用 git 安装和手动 zip 安装。我还确保在我的 httpd.conf
文件中我已打开重写
LoadModule rewrite_module modules/mod_rewrite.so
我不确定还要查找什么。谷歌搜索一直返回 htaccess 文件丢失的结果。
编辑
这是每个请求的 htaccess 文件。如果我将我的项目保存在 MAMP 的 htdocs 目录中,它是默认的。我尝试取消对 RewriteBase 的注释并将其设为 /
(总的猜测),但这根本没有帮助。
# Kirby .htaccess
# rewrite rules
<IfModule mod_rewrite.c>
# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on
# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /
# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]
# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]
# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) index.php [L]
# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]
# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on
Mike Rockett 在评论中为我指出了正确的方向。在 httpd.conf
文件中,我必须更改
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
到
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
然后我重新启动了 MAMP,它成功了!
我正在尝试使用 MAMP 在本地设置 Kirby。我有我的 MAMP 设置,所以我可以将 运行 多个站点作为虚拟主机。我使用此代码:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Users/oscargodson/Dropbox/projects/icarus"
ServerName dev.icarus
</VirtualHost>
当我转到 dev.icarus 时,初始页面加载完全正常。所有 CSS,图像,一切。一旦我尝试转到子页面,包括面板,我得到 404。我确定 htaccess 文件在文件夹中。我尝试使用 git 安装和手动 zip 安装。我还确保在我的 httpd.conf
文件中我已打开重写
LoadModule rewrite_module modules/mod_rewrite.so
我不确定还要查找什么。谷歌搜索一直返回 htaccess 文件丢失的结果。
编辑
这是每个请求的 htaccess 文件。如果我将我的项目保存在 MAMP 的 htdocs 目录中,它是默认的。我尝试取消对 RewriteBase 的注释并将其设为 /
(总的猜测),但这根本没有帮助。
# Kirby .htaccess
# rewrite rules
<IfModule mod_rewrite.c>
# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on
# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /
# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]
# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]
# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) index.php [L]
# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]
# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on
Mike Rockett 在评论中为我指出了正确的方向。在 httpd.conf
文件中,我必须更改
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
到
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
然后我重新启动了 MAMP,它成功了!