服务器:Apache

我正在寻找以下列方式重写我的网址,而我无法想办法让它发挥作用。

http://website.com/index.html

我希望它重定向到:

http://website.com/

所以基本上我想加载index.html,但不要在url中显示它。我也不想给它另一个名字。我不是在寻找 /index.html 来成为 / index

此外,我正在尝试获取任何GET数据,例如:

http://website.com/index.html?id=0&name="fred"

重写为:

http://website.com/?id=0&name="fred".

如果您的解决方案没有使用.htaccess文件也可以。

有帮助吗?

解决方案

我相信这应该有效:

RewriteEngine on
RewriteRule ^index\.html(.*)$ /$1 [R=permanent,L]

这会将以 /index.html 开头的所有请求重定向到“ / ”并将保留 index.html

之后的任何参数

其他提示

对于.htaccess文件:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /index\.html
RewriteRule ^index\.html$ / [L,R=301]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top