将无效的 URL 传递给网页代码
Passing an invalid URL to web page code
我想知道以下是否可行:
如果网站访问者输入错误的 URL 路径,我希望在页面上显示无效路径。
示例: 访问者转到 www.Whosebug。com/made_up_domain_path
我希望他们被带到任何不正确路径的页面显示类似的内容; "I'm sorry 'made_up_domain_path' is not a valid page."
我不确定 .htaccess 是否可以用于此目的。我目前在 .htaccess 中有以下内容:
ErrorDocument 404 /error.html
重定向到基本 "page not found" 页面。
这是可以实现的吗?
如有任何帮助,我们将不胜感激。提前致谢。
我使用以下 javascript 完成了这项工作:
window.location.pathname + window.location.hash;
这返回了 URL 中“/”之后的所有内容。
我想知道以下是否可行:
如果网站访问者输入错误的 URL 路径,我希望在页面上显示无效路径。
示例: 访问者转到 www.Whosebug。com/made_up_domain_path
我希望他们被带到任何不正确路径的页面显示类似的内容; "I'm sorry 'made_up_domain_path' is not a valid page."
我不确定 .htaccess 是否可以用于此目的。我目前在 .htaccess 中有以下内容:
ErrorDocument 404 /error.html
重定向到基本 "page not found" 页面。
这是可以实现的吗?
如有任何帮助,我们将不胜感激。提前致谢。
我使用以下 javascript 完成了这项工作:
window.location.pathname + window.location.hash;
这返回了 URL 中“/”之后的所有内容。