通过.htaccessredirect到shebang的path?

我有一小部分代码可以将从我自己的域访问的页面redirect到他们的哈希地址,如下所示:

example.com/stationary.html => example.com/#/stationary 

这是代码:

 <IfModule mod_rewrite.c> # Redirect requests to ajax pages the their hashes RewriteCond $1 !=index [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https?://(www\.)?example\.com/ [NC] RewriteRule ^([a-zA-Z0-9\-_]+)\.html?$ /#$1 [NE,R] </IfModule> 

这将工作很好,现在我想知道我可以得到它redirect页面

 example.com/stationary => example.com/#!/stationary 

黑客上面的代码没有工作。 任何帮助,将不胜感激!
谢谢!

我不确定你认为“哈希地址”是什么; 其中包含散列标记的URL指的是所涉页面上的锚点并不是本身的资源。

有关详细信息,请参阅RFC 2616。

无论如何,至于你的问题:你将不得不重复整个规则,包括所有的RewriteConds,以匹配其他的东西。

 RewriteCond $1 ! \.html?$ [NC] ... RewriteRule ^([a-zA-Z0-9_-]+)$ /#!/$1 [NE,R] 

另外,将“ ”移动到集合的末尾,这样就不必转义它。

哦,摆脱IfModule; 你会知道是否加载或不。