开发者

htaccess rewrite to hash for ajax

开发者 https://www.devze.com 2023-01-30 13:02 出处:网络
Basically I\'d like to emulate what Hypem.com does with their urls, if you go to hypem.com/popular you get redirected to hypem.com/#/popular

Basically I'd like to emulate what Hypem.com does with their urls, if you go to hypem.com/popular you get redirected to hypem.com/#/popular

How can I do this with htac开发者_如何学JAVAcess? I have several basic urls that I need to redirect, all others stay the same, for example, these two need to redirect:

  • /news
  • /contact

But /admin shouldn't


This code worked for me:

## REWRITE RULES
# enable rewrite
RewriteEngine On
RewriteBase /
RewriteRule ^(news|contact)(/?)(.*)$ #/$1$2$3 [R,NC,NE,L]


It looks to me like they do it with javascript:

url = document.location.pathname + document.location.search;
url = url.replace(/\?ax=1/,'');
url = "/#" + url;
top.location = url;

That is from the source of http://hypem.com/popular

0

精彩评论

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