Apache does not find URL

Asked

Viewed 86 times

0

I developed my page using angular

Only that by giving the ng build --prod --bh=/projeto/

When I want to access my system by sending a parameter via url

The same only works if you are using the previous

{provide: LocationStrategy, useClass: HashLocationStrategy}

Which I would access

  http://localhost/projeto/#/parametro

I would like to access without needing to use the Hashlocationstrategy, but when I shoot and give a ng build --prod --bh=/projeto/, and I try to access without the hash strategy, like this:

  http://localhost/projeto/parametro

He gives Not Found

The requested URL /projeto/parametro was not found on this server.

But when accessing just like this

http://localhost/projeto/

He thinks

How do I access without having to hash.

My Apache is already activated

LoadModule rewrite_module modules/mod_rewrite.so

1 answer

1

As an alternative to HashLocationStrategy you can implement this rewrite rule in your .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on

# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]

  • When the ng build --prod --bh=/projeto/ give it to me Uncaught SyntaxError: Unexpected token < On the server, but if I take the --prod, works

Browser other questions tagged

You are not signed in. Login or sign up in order to post.