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

半世苍凉 提交于 2020-01-07 02:53:03

问题


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:


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.



来源:https://stackoverflow.com/questions/5526203/how-to-use-mod-rewrite-with-anchors-but-no-r-301

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!