Skip to main content
added 681 characters in body
Source Link
CodeMed
  • 5.4k
  • 50
  • 111
  • 152

An Amazon Linux 2 instance is using Apache to host an Angular 7 app. The Angular 7 app includes not just index.html, but also several .js files and a subdirectory named assets.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot? Note that the required syntax needs to also allow all the .js files and the contents of the assets directory to be served as secondary requests when the client browsers are loading index.html.

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html. And then index.html must be able to get access to the .js files and the contents of the assets subdirectory.

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes302 here^/(?"!index.html$).+ http://mydomain.com  
</VirtualHost>
**First Attempt**Forensic Analysis of Results
I tried the following, but the result was that `mydomain.com` seemed to load an empty page for every URL requested byWhen try
browser.RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.comWhen I open upabove with
open
I
What gives with this?
**Second Attempt:**
ThenAlso, when
triedview
following`html` page source for the same request
which led to a responseI see
server didcontents of `index.html` were indeed served correctly, but that the browser remained empty because the code in `index.html` was
understandable to access
request for any path, including`.js` files or
root path:RewriteEngine onRewriteRulecontents of the `assets` subdirectory.>So the problem is that `RedirectMatch 302
(?!index
* indexhtml$)
html+ http://mydomain.com ` needs to be re-written to allow for the `.js` files and for the contents of the `assets` subdirectory. **What specific syntax is required to resolve this so that Apache can successfully server up the Angular 7 app no matter what character string is added after http://mydomain.com?**

An Amazon Linux 2 instance is using Apache to host an Angular 7 app.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot?

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html.

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes here?"
</VirtualHost>
**First Attempt
I tried the following, but the result was that `mydomain.com` seemed to load an empty page for every URL requested by
browser.RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.comWhen I open up
What gives with this?
**Second Attempt:**
Then
tried
following
which led to a response
server did
understand
request for any path, including
root path:RewriteEngine onRewriteRule
* index
html

An Amazon Linux 2 instance is using Apache to host an Angular 7 app. The Angular 7 app includes not just index.html, but also several .js files and a subdirectory named assets.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot? Note that the required syntax needs to also allow all the .js files and the contents of the assets directory to be served as secondary requests when the client browsers are loading index.html.

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html. And then index.html must be able to get access to the .js files and the contents of the assets subdirectory.

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com  
</VirtualHost>
**Forensic Analysis of Results
When try
above with
open
I
Also, when
view
`html` page source for the same request
I see
contents of `index.html` were indeed served correctly, but that the browser remained empty because the code in `index.html` was
able to access
`.js` files or
contents of the `assets` subdirectory.>So the problem is that `RedirectMatch 302
(?!index
html$)
+ http://mydomain.com ` needs to be re-written to allow for the `.js` files and for the contents of the `assets` subdirectory. **What specific syntax is required to resolve this so that Apache can successfully server up the Angular 7 app no matter what character string is added after http://mydomain.com?**
added 468 characters in body
Source Link
CodeMed
  • 5.4k
  • 50
  • 111
  • 152

An Amazon Linux 2 instance is using Apache to host an Angular 7 app.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot?

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html.

(In this case, DocumentRoot is a directory entitled /var/www/mydomain.com/public_html). Also, the /var/www/mydomain.com/public_html directory includes 1. index.html, 2. several .js files, and 3. an assets subdirectory containing things like images, etc.)

I would like to use RedirectMatch inside of a VirtualHost block to keep the configuration as clean as possible. Here is what I have in mind. How does the following need to be modified?

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes here?"
</VirtualHost>

**Attempts**First Attempt:**
I tried the following, but the result was that `mydomain.com` seemed to load an empty page for every URL requested by the browser. RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com ThenWhen I open up the Network Tab in the Developer Tools of Firefox and make a request to `http://mydomain.com` while the `RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com` is in the `VirtualHost`, the result is that all requests to `/` are shown to have given a `304` response, while all requests to named files like scripts and stylesheets are shown to have given `302` responses. What gives with this?
**Second Attempt:**
Then I tried the following, which led to a response that the server did not understand the request for any path, including the root path: RewriteEngine on RewriteRule ^/.* index.html

An Amazon Linux 2 instance is using Apache to host an Angular 7 app.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot?

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html.

(In this case, DocumentRoot is a directory entitled /var/www/mydomain.com/public_html).

I would like to use RedirectMatch inside of a VirtualHost block to keep the configuration as clean as possible. Here is what I have in mind. How does the following need to be modified?

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes here?"
</VirtualHost>

**Attempts:**
I tried the following, but the result was that `mydomain.com` seemed to load an empty page for every URL requested by the browser. RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com Then I tried the following, which led to a response that the server did not understand the request for any path, including the root path: RewriteEngine on RewriteRule ^/.* index.html

An Amazon Linux 2 instance is using Apache to host an Angular 7 app.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot?

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html.

(In this case, DocumentRoot is a directory entitled /var/www/mydomain.com/public_html. Also, the /var/www/mydomain.com/public_html directory includes 1. index.html, 2. several .js files, and 3. an assets subdirectory containing things like images, etc.)

I would like to use RedirectMatch inside of a VirtualHost block to keep the configuration as clean as possible. Here is what I have in mind. How does the following need to be modified?

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes here?"
</VirtualHost>

**First Attempt:**
I tried the following, but the result was that `mydomain.com` seemed to load an empty page for every URL requested by the browser. RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com When I open up the Network Tab in the Developer Tools of Firefox and make a request to `http://mydomain.com` while the `RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com` is in the `VirtualHost`, the result is that all requests to `/` are shown to have given a `304` response, while all requests to named files like scripts and stylesheets are shown to have given `302` responses. What gives with this?
**Second Attempt:**
Then I tried the following, which led to a response that the server did not understand the request for any path, including the root path: RewriteEngine on RewriteRule ^/.* index.html
added 436 characters in body
Source Link
CodeMed
  • 5.4k
  • 50
  • 111
  • 152

An Amazon Linux 2 instance is using Apache to host an Angular 7 app.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot?

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html.

(In this case, DocumentRoot is a directory entitled /var/www/mydomain.com/public_html).

I would like to use RedirectMatch inside of a VirtualHost block to keep the configuration as clean as possible. Here is what I have in mind. How does the following need to be modified?

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes here?"
</VirtualHost>

**Attempts:**
I tried the following, but the result was that `mydomain.com` seemed to load an empty page for every URL requested by the browser. RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com Then I tried the following, which led to a response that the server did not understand the request for any path, including the root path: RewriteEngine on RewriteRule ^/.* index.html

An Amazon Linux 2 instance is using Apache to host an Angular 7 app.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot?

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html.

(In this case, DocumentRoot is a directory entitled /var/www/mydomain.com/public_html).

I would like to use RedirectMatch inside of a VirtualHost block to keep the configuration as clean as possible. Here is what I have in mind. How does the following need to be modified?

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes here?"
</VirtualHost>

An Amazon Linux 2 instance is using Apache to host an Angular 7 app.

What specific syntax do I need to use in order to ensure that requests to Apache for all non-specified routes get redirected to the index.html located in the DocumentRoot?

For example, if a remote web browser requests mydomain.com/randomCharacters, I want Apache to return index.html the same way that Apache would respond to a request to mydomain.com with index.html.

(In this case, DocumentRoot is a directory entitled /var/www/mydomain.com/public_html).

I would like to use RedirectMatch inside of a VirtualHost block to keep the configuration as clean as possible. Here is what I have in mind. How does the following need to be modified?

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
    RedirectMatch "What goes here?"
</VirtualHost>

**Attempts:**
I tried the following, but the result was that `mydomain.com` seemed to load an empty page for every URL requested by the browser. RedirectMatch 302 ^/(?!index.html$).+ http://mydomain.com Then I tried the following, which led to a response that the server did not understand the request for any path, including the root path: RewriteEngine on RewriteRule ^/.* index.html
Source Link
CodeMed
  • 5.4k
  • 50
  • 111
  • 152
Loading