H
H
Hipster_John2014-02-01 17:56:03
JavaScript
Hipster_John, 2014-02-01 17:56:03

How to setup .htaccess for successful _escaped_fragment_ redirect?


One of the best examples of this new technique is a rather large website - the new version of Twitter. If you are a registered user of the Twitter microblogging service and you have Javascript, you can view the profile by clicking on the following link: https://twitter.com /#!/Hibster_John

However, Twitter wants to maintain compatibility while still having attractive indexed URLs, which is why they use 301 redirects: twitter.com/Hibster_John
Link source

The question is that no matter how much I searched for the correct redirect, I did not find it on Twitter, and my site works identically to Twitter. Please tell me the code required for a normal CNC.
Site example
mysite.ru/#!/page_Home
mysite.ru/#!/page_ABOUT
etc.
I would like to see
mysite.ru/page_Home
mysite.ru/page_ABOUT
etc.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
Hipster_John, 2014-02-01
@Hipster_John

If you take this code:

As the URL fragment is not transmitted to the server, you can only use a client side solution. Here’s one using JavaScript:

if (location.href.indexOf("#") > -1) {
    location.assign(location.href.replace(/\/?#/, "/"));
}
This simply checks if there is a # in the URL and replaces the first occurrence with /. So /site/#blog would get /site/blog.

So what should it look like in my case with /#!/ and not /# ?

K
kompi, 2014-02-01
@kompi

The question is solved not by Apaches, but by js.
It's strange that you didn't google stackoverflow right away .
To summarize: the url part with the hashtag does not go to the server.
For example, when requested http://mysite.ru/#!/page_Home, the piece #!/page_Homewill be thrown back by the browser.

F
frees2, 2014-02-01
@frees2

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^#!/index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
 </IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question