如何在锚点上使用mod_rewrite,但不使用[R = 301] [英] How to use mod_rewrite with anchors but no [R=301]
问题描述
我有一个基于jQuery scrollTo插件的网站.每个页面都可以通过锚点访问,即. www.domain.com/#page-one 更深 www.domain.com/#page-one--some-content .
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.
我想使用mod_rewrite创建规则,因此地址
I'd like to create rule with mod_rewrite so address like
www.domain.com/page-one 或者 www.domain.com/page-one/some-content
指向上面的一个.使用[R = 301]标志非常容易,但是我需要我的干净"地址/page-one/some-content 留在地址栏中,不要更改为#page-one--某些内容.
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.
为什么我需要更改它们?因为某些原因,我需要使用MSIE和Opera的替代站点,这种常规站点需要重新加载每个页面.我认为两个站点都需要相同的链接,这很明显.
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.
我花了很多时间来挖掘&阅读有关URL和内容的锚点的信息,但我还没有达到我的目标.如果有人可以帮助我,我将不胜感激!
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!
谢谢库巴.
推荐答案
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule (.*) /index.php#$1 [NE]
这对我来说很好.
这篇关于如何在锚点上使用mod_rewrite,但不使用[R = 301]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!