L
L
li4e2015-05-30 22:03:44
Angular
li4e, 2015-05-30 22:03:44

How to setup .htaccess for seo friendly angularjs app?

There is the following .htaccess setting

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$
    RewriteCond %{REQUEST_URI} !"/static/"
        RewriteRule ^(.*)$ /static/index.php [R=302,L]

    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Rewrite everything else to index.html to allow html5 state links
    RewriteRule ^ index.html [L]


</IfModule>

This setting is tailored for html5 addressing, and if the get parameter "_escaped_fragment_=" is present, it will redirect to the "static" folder, which will contain a php script that will return the html pages of the corresponding routes.
But the problem is that I don't know how to pass information about the current page to the script.
Suppose in an angularjs application, the pages have, for example, the following addresses: site.ru/blog, site.ru/blog/2, site.ru
How can I transfer information about the current route using htaccess?
For example in the form of a request, something like this view=blog, id=2
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ShamblerR, 2015-06-01
@ShamblerR

%{REQUEST_URI} + %{QUERY_STRING} doesn't suit you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question