Skip to content

Instantly share code, notes, and snippets.

@jxnblk
Last active March 12, 2023 12:25
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save jxnblk/6137537 to your computer and use it in GitHub Desktop.
Save jxnblk/6137537 to your computer and use it in GitHub Desktop.
.htaccess for using AngularJS's in HTML5 mode on Media Temple
Options +FollowSymLinks
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>
@Francisc
Copy link

Can you please comment what each lines does?

@juliogc
Copy link

juliogc commented Jul 7, 2014

When I access a direct link "myapp.com/user-settings" it crashes the browser.

@tiberiu80
Copy link

Can you please adapt it to work for html5mode in legacy browsers for deep linking? Works fine in ie10+ but in ie9 when i have a route like domain/route/:id it fails to fallback to hasbang mode domain/#!/route/:id which leads to not loading jsvascript and css. If you can provide a solution i will be much obliged. Ty.

@jaredrethman
Copy link

Works great - thanks a billion!

@mmguide2003
Copy link

Not working for me. Redirects example.com -> example.com/#/

@josejulio
Copy link

@mmguide2003 it also happens the same to me, did you find a workaround?

@narenthiran
Copy link

Awesome. Thanks for sharing 😊

@GaiusValerius
Copy link

@josejulio @mmguide2003 You need to enable the HTML5-Mode:
function($locationProvider) {
$locationProvider.html5Mode(true);
},

@odera89
Copy link

odera89 commented May 6, 2015

Hello,

For simple link it's working fine ex." http://clean-blog.dev/about " but ex. for this link: " http://clean-blog.dev/page/2" only on refresh doesn't work.
Any suggestion?

@alcalyn
Copy link

alcalyn commented Dec 6, 2015

Same here, refreshing works only for first level of path (/articles works, /articles/article-slug not working).

@PH-F
Copy link

PH-F commented Jul 7, 2016

This works fine, but i get errors in the console
Failed to parse SourceMap: URL/vendor/reflect-metadata/Reflect.js.map
Failed to parse SourceMap: URL/vendor/@angular/core/src/metadata.js.map
etc.

How can i exclude them

@vistajess
Copy link

Hello , I have same problem as well.

I have route app/dashboard redirect from my login page(index).
When the user is logged in it redirects to app/dashboard, the route perfectly shows but
when I refresh the page it returns 404 `The requested URL /dashboard was not found on this server.``

Any insights pls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment