Htaccess rewrite to hash for ajax

Basically, I would like to emulate what Hypem.com does with their URLs, if you go to hypem.com/popular you will get redirected to hypem.com/#/popular

How to do this using htaccess? I have several basic URLs that I need to redirect, all the rest remain the same, for example, these two need to be redirected:

  • /news
  • /contact

But /admin should not

+4
source share
2 answers

This code worked for me:

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

It seems to me that they do this using javascript:

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

This is from http://hypem.com/popular

+2
source

Source: https://habr.com/ru/post/1332231/


All Articles