用htaccess再次困住 . 如何将404页面添加到特定子目录?
在我的情况下,404页面应仅影响“ staging ”子目录(以及分段内的目录),但不影响根或放在root中的任何其他子目录 .
http://example.com/ staging
我的.htaccess文件中的目录“staging”的代码:
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [L]
Options -Indexes -MultiViews
RewriteEngine on
RewriteRule ^arbeiten/$ /staging/arbeiten/alle [R=301,L]
RewriteRule ^journal/$ /staging/journal/journal-alle [R=301,L]
ErrorDocument 404 /staging/404.html
使用上面的代码(以及许多其他代码)会导致内部服务器错误 .
1 回答
Update #1 至我最初的问题 . 通常,将404未找到的页面添加到特定子目录所提供的代码/答案有效:
它仍然不起作用的原因是因为与代码 remove .html 扩展和/或 redirect to a page in a folder 相关的整体.htaccess设置中必定存在一些错误 .
我将继续进一步调查我的.htaccess中的设置 .
Update #2 使用下面的.htaccess脚本可以删除.html扩展名,将页面重定向到目录中的特定页面,基本上是Hostgator cPanel网格托管(apache)上特定子目录中的404未找到页面 .
剩下的404问题:
http://example.com/staging/blabla(404作品)
http://example.com/staging/folder/blala(404作品)
http://example.com/staging/folder/project-detail-pagexxx(404作品)
http://example.com/staging/folder/project-detail-pagexxx / (404不起作用)