Ann*_*ber 16 html .htaccess redirect apache2
我将一个庞大而复杂的网站变成了一个小型的单页网站,因此需要将用户从404重定向到index.html.
我把它放在.htaccess中:
ErrorDocument 404 /index.html
Run Code Online (Sandbox Code Playgroud)
如果您输入mydomain.com/lalalalala,则会重定向到主页内容(mydomain.com/index.html),但URL栏仍然显示为mydomain.com/lalalalala.
如何将404重定向到index.html并将URL重写为mydomain.com?
编辑:
我正在使用Bluehost.
anu*_*ava 24
您可以在.htaccess的顶部使用这两行:
DirectoryIndex index.html
ErrorDocument 404 http://domain.com/
Run Code Online (Sandbox Code Playgroud)
DirectoryIndex默认情况下会http://domain.com/加载http://domain.com/index.html,使用http://in ErrorDocument会使其重定向到新的URL.