Get rid of the first condition. The #
part of the URL is never sent to the server so there's no way for you to match against it. Then change the rule to this:
RewriteRule ^(.+)$ /#!/$1 [L,R,NE]
Pergunta
I have this site, say http://example.com/
. I want all requests to redirect (the user has to see the url in his address bar) to http://example.com/#!/the_requested_page
.
So this is what I want to happen:
http://example.com/
=> Show http://example.com/
http://example.com/somepage
=> Show http://example.com/#!/somepage
http://example.com/#!/somepage
=> Show http://example.com/#!/somepage
How can this be done with the .htaccess file?
I tried this, but it doesn't do the second part of the list above.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/#!/
# Don't apply to URLs that go to existing files or folders
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /#!/$1 [L]
If I request http://example.com/somepage
it shows that in the address bar, but the website shows the home page (http://example.com
).
Besides that, this doesn't redirect, but it just rewrites...
I hope you can help me out.
Solução
Get rid of the first condition. The #
part of the URL is never sent to the server so there's no way for you to match against it. Then change the rule to this:
RewriteRule ^(.+)$ /#!/$1 [L,R,NE]