Last active
February 23, 2022 03:59
-
-
Save leocaseiro/4305e06948aa97e77c93 to your computer and use it in GitHub Desktop.
Angular html5Mode apache working in a subdirectory /app using ngRoute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <IfModule mod_rewrite.c> | |
| RewriteEngine on | |
| RewriteCond %{REQUEST_FILENAME} -s [OR] | |
| RewriteCond %{REQUEST_FILENAME} -l [OR] | |
| RewriteCond %{REQUEST_FILENAME} -d | |
| RewriteRule ^.*$ - [NC,L] | |
| RewriteRule ^(.*) /app/index.html [NC,L] | |
| </IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var app = angular.module('myApp', ['ngRoute']) | |
| .config(function($routeProvider, $locationProvider) { | |
| $routeProvider.when('/list', | |
| { | |
| templateUrl: 'templates/list.html', | |
| controller: 'ListController' | |
| }); | |
| $routeProvider.when('/new', | |
| { | |
| templateUrl: 'templates/new.html', | |
| controller: 'EditController' | |
| }); | |
| //Default URL | |
| $routeProvider.otherwise({redirectTo:'list'}); | |
| }) | |
| ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html ng-app="myApp"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title>List</title> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <base href="/app/"> | |
| <meta name="fragment" content="!" /> | |
| </head> |
awesome, thanks!
Suuuper Awersomeeeee meaaan!
This is great! Thank you!
sweet!
Thank you it worked for me also.
@leocaseiro What to do to work in subroutes?
# Refresh works
app.com/route-a
# Refresh don't work
app.com/child-route/route-b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this... i was looking for dets on how to write my .htaccess file to work with angulars ugly hashed URLS.