Ashley
Ashley

Reputation: 5947

htaccess rewrite to hash for ajax

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 htaccess? I have several basic urls that I need to redirect, all others stay the same, for example, these two need to redirect:

But /admin shouldn't

Upvotes: 3

Views: 2551

Answers (2)

Sonny
Sonny

Reputation: 8326

This code worked for me:

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

Upvotes: 3

zsalzbank
zsalzbank

Reputation: 9857

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

Upvotes: 2

Related Questions