Quantcast
Channel: Apache rewrite any uri to index.html but existing files - Server Fault
Viewing all articles
Browse latest Browse all 2

Apache rewrite any uri to index.html but existing files

$
0
0

My front-end project is based on 1 file: frontend/index.html

It means that every request like /contact, /about, etc should be responded by index.html file.

I was thought I can use these lines in my httpd.conf file with no any conditions:

<VirtualHost *:80>    DocumentRoot "/var/www/frontend/"    RewriteEngine On    RewriteRule . /var/www/frontend/index.html</VirtualHost>

But I understood that any existing files (such as frontend/js/app.js or frontend/favicon.ico etc) will also be responded by the index.html while they exist in real directories.

This is what I need:

Request: /contact -> No frontend/contact file -> Response: index.html

Request: / -> No file requested -> Response: index.html

Request: /js/app.js -> frontend/js/app.js exists -> Response: frontend/js/app.js

etc.

What can I write in httpd.conf file in above block to do such thing?

NOTE: I used VirtualHost because I need the back-end files in another port (:8080) of server requests.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>