How to use mod_rewrite with anchors but no [R=301]

2019-08-31 07:24发布

I have a website build on jQuery scrollTo plugin. Each page is accessible via anchor's, ie. www.domain.com/#page-one and deeper www.domain.com/#page-one--some-content.

I'd like to create rule with mod_rewrite so address like

www.domain.com/page-one or www.domain.com/page-one/some-content

point to the above one. Its quite easy with [R=301] flag but I need my "clean" address /page-one/some-content to stay in address bar not changing to #page-one--some-content.

Why I need to change them? Because for some reasons I need to use alternative site for MSIE and Opera, kind of regular one with reloading every page. I need the same links for both sites which is obvious, I think.

I spent lots of time digging & reading about anchors in URL's and stuff, but I haven't reach my goal. If any one can help me, I'll appreciate!

Thanks, Kuba.

1条回答
欢心
2楼-- · 2019-08-31 07:57
Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule (.*) /index.php#$1 [NE]

This works excellent for me.

查看更多
登录 后发表回答