Don Rhummy Don Rhummy - 1 year ago 45
Apache Configuration Question

How make htaccess for single-page app within a sub-path in URL?

I want to have a single-page app, but only within a sub URL like:

//The following would all be valid, but handled by the "index.html"
//at http://www.test.com/webapp
http://www.test.com/webapp
http://www.test.com/webapp/settings
http://www.test.com/webapp/start


I want all the URLs to look exactly like above, but be handled by:
http://www.test.com/webapp/index.html
.

I also want the following URLs to not be handled by that page:

http://www.test.com
http://www.test.com/contact
http://www.test.com/about


How do I do this?

REGULAR SINGLE_PAGE HTACCESS

<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html [QA,L]
</ifModule>

Answer Source

Just adding answer for reference.

The commnet from Croise:

"The same (with [QSA] not [QA]) but in the webapp directory"

Worked for me.

The ".htaccess" must be on the subdieretory.

Example working ".htaccess":

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.html [QSA,L]
</ifModule>

The only diference is "[QA,L]" to "[QSA,L]"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download