开发者

.htaccess remove file extension before hashtag

http://freddygonzalez.me/dev/update/index.html#mywork.html

How can I use .htaccess to remove the index.html

So it could look like this http://freddygonzalez.me/dev/update/#mywork.html

Also there may be one conflict.If the user press on the logo they get this http://fredd开发者_JS百科ygonzalez.me/dev/update/index.html#index.html

So is there a way to use.htaccess to always remove the index.html but not the hashtag?

Thanks


The fragment of a URL is not sent to the server, it’s meant for local usage only:

[…] the fragment identifier is not used in the scheme-specific processing of a URI; instead, the fragment identifier is separated from the rest of the URI prior to a dereference, and thus the identifying information within the fragment itself is dereferenced solely by the user agent, regardless of the URI scheme.

So there is no way to remove it from a request with mod_rewrite since the server doesn’t know anything about the fragment.

But the client obviously does know. So you can use some client side techniques like JavaScript to remove or adjust the fragment.


Well as per jadew's comment, if the hash makes it to the server this should match it.

RewriteEngine On
RewriteRule ^(dev/update/)index\.html(#.+\.html)$ $1$2 [L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜