# Apache rewrite rule for HTML5 browser history URL bookmarkability

**URL:** <https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013>\
**Category:** Uncategorized\
**Created:** [April 17, 2013, 6:18pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013 "2013-04-17T18:18:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![stusalsbury](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/stusalsbury/32/14560_2.png) [@stusalsbury](https://discuss.emberjs.com/u/stusalsbury)\
**Post date:** [April 17, 2013, 6:18pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/1 "2013-04-17T18:18:07Z")

</div>

I found a bunch of examples on the web of Apache rewrite rules that people are using for AJAX-based HTML5-history-using sites. All of them didn’t work for me. I don’t know why. But I thought it was Ember’s fault. It wasn’t. So I spun my wheels for a while blaming the router. It wasn’t. It’s just that there are some strange examples of rewrite rules on the web for AJAX-based HTML5-history-using sites. Anyway, I’m posting so nobody else gets caught up blaming Ember’s router. We can blame the router for other things 😉 JK: I’m in love with Ember, so I can tease. Maybe this will help someone else who’s just getting started.

Below is what worked for me. I wanted to send every request for URLs to index.html, except for certain subdirectories (js, css, img, svc). If you do this in the root of your Apache config, you might need to specify a forward slash. If you don’t use Apache, then you don’t care 😃.

```
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(js|css|img|svc)($|/) - [L]
RewriteRule ^(.*)$ index.html [L]

```

---

<div class="post-metadata">

**Author:** ![owz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/owz/32/3618_2.png) [@owz](https://discuss.emberjs.com/u/owz)\
**Post date:** [April 20, 2013, 9:13pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/2 "2013-04-20T21:13:16Z")

</div>

Thanks for the post. I’ve been looking to do the same thing too. I found this post helpful: [http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/](http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/)

---

<div class="post-metadata">

**Author:** ![ishwinder](https://avatars.discourse-cdn.com/v4/letter/i/7ba0ec/32.png) [@ishwinder](https://discuss.emberjs.com/u/ishwinder)\
**Post date:** [April 23, 2013, 10:11am UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/3 "2013-04-23T10:11:05Z")

</div>

This helped a lot in configuring routes for my app. Thanks for the link !!

---

<div class="post-metadata">

**Author:** ![abobwhite](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/abobwhite/32/15085_2.png) [@abobwhite](https://discuss.emberjs.com/u/abobwhite)\
**Post date:** [February 12, 2014, 4:41pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/4 "2014-02-12T16:41:02Z")

</div>

Thanks, all! This was my savior after hours of searching and tweaking. The solution on the page provided by @owz ended up being what I needed.

---

<div class="post-metadata">

**Author:** ![abobwhite](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/abobwhite/32/15085_2.png) [@abobwhite](https://discuss.emberjs.com/u/abobwhite)\
**Post date:** [February 12, 2014, 4:42pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/5 "2014-02-12T16:42:23Z")

</div>

Also, in Apache 2.2.16+, you can use a much simpler method which I have confirmed works:

```
FallbackResource /index.html

```

---

<div class="post-metadata">

**Author:** ![sheriffderek](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/sheriffderek/32/10619_2.png) [@sheriffderek](https://discuss.emberjs.com/u/sheriffderek)\
**Post date:** [April 5, 2015, 9:58pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/6 "2015-04-05T21:58:10Z")

</div>

As of this date, this worked great for me with ember 1.11.1 etc. CLI 2.2

---

<div class="post-metadata">

**Author:** ![joshkg](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/joshkg/32/13322_2.png) [@joshkg](https://discuss.emberjs.com/u/joshkg)\
**Post date:** [September 7, 2017, 7:30pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/7 "2017-09-07T19:30:11Z")

</div>

The Apache rewrite rules mentioned in @owz’s post worked for me for Apache 2.2.31:

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

```

---

<div class="post-metadata">

**Author:** ![leandrobortolotto](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/leandrobortolotto/32/13441_2.png) [@leandrobortolotto](https://discuss.emberjs.com/u/leandrobortolotto)\
**Post date:** [October 18, 2017, 10:53pm UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/8 "2017-10-18T22:53:00Z")

</div>

@joshkg I’m using Apache 2.4 and facing this same issue. Where exactly did you include this configuration? In the `httpd.conf` file? If so, in what part of the file? Inside a `<VirtualHost>` tag or outside? Could you share a code snippet of your config file including this config “surrounds”, please? Thank you

---

<div class="post-metadata">

**Author:** ![plebeian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/plebeian/32/13954_2.png) [@plebeian](https://discuss.emberjs.com/u/plebeian)\
**Post date:** [October 19, 2017, 12:14am UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/9 "2017-10-19T00:14:28Z")

</div>

Cool. Is this supposed to work for all routes, or only root index? Doesn’t seem to work for me on individual routes.

---

<div class="post-metadata">

**Author:** ![joshkg](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/joshkg/32/13322_2.png) [@joshkg](https://discuss.emberjs.com/u/joshkg)\
**Post date:** [October 19, 2017, 1:34am UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/10 "2017-10-19T01:34:20Z")

</div>

I actually have mine in a .htaccess file.

---

<div class="post-metadata">

**Author:** ![leandrobortolotto](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/leandrobortolotto/32/13441_2.png) [@leandrobortolotto](https://discuss.emberjs.com/u/leandrobortolotto)\
**Post date:** [October 19, 2017, 1:37am UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/11 "2017-10-19T01:37:18Z")

</div>

I ended up using the same solution as @abobwhite mentioned. Very simple and efficient. I just added

> FallbackResource /index.html

at the end of

> /etc/httpd/conf/httpd.conf

file.

---

<div class="post-metadata">

**Author:** ![Amit\_Choudhary](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/amit_choudhary/32/14015_2.png) [@Amit\_Choudhary](https://discuss.emberjs.com/u/Amit_Choudhary)\
**Post date:** [June 2, 2018, 9:22am UTC](https://discuss.emberjs.com/t/apache-rewrite-rule-for-html5-browser-history-url-bookmarkability/1013/12 "2018-06-02T09:22:18Z")

</div>

I tired so many setting final this solution work for me. In my case I applied both as following:

1. update .htaccess file
2. As a backup append line in “FallbackResource /” /etc/apache2/apache2.conf

Note:

- In machine I don’t have httpd.conf file after install apache2. I used to update apache2.conf file.
- I removed index.html because this can be vary if we use .php, .html or any other file that’s why I use root option as “/” only.

But my problem solved after 2nd step.
