0

I have configured following route which takes 2 path components, works perfectly fine on local server with base href="/" in index.html. I had to change base href="/" to base href="./" while deploying in production server as a result the routes are not working. What am I doing wrong here.

const routes : Routes =[{path:":firstPathComponant/:secondPathComponant", component: HomeComponent}]

.htaccess

  Options +FollowSymLinks
  IndexIgnore */*
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.*) index.html
5
  • I guess you need to search for how to enable HTML5 pushState on Apache. Commented Apr 11, 2017 at 17:23
  • It would probably better to edit your question and add the code there to preserve formatting. Commented Apr 11, 2017 at 18:09
  • @GünterZöchbauer I updated question to include .htaccess can you please let me know what am I doing wrong? Commented Apr 11, 2017 at 18:11
  • Is your application in the root directory of the domain, or in the sub-folder? Commented Apr 11, 2017 at 18:15
  • its under /public_html/somefolder/ Commented Apr 11, 2017 at 18:16

1 Answer 1

1

According to Angular Documentation:

If the app folder is the application root, as it is for the sample application, set the href value exactly as shown here.

If your production URL is http://domain.tld/somefolder, you should set the href value to <base href="/somefolder">

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.