如何在URL的子路径内对单页应用程序进行htaccess?

Don*_*mmy 4 apache .htaccess

我希望有一个单页应用程序,但只能在一个子网址中,例如:

//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
Run Code Online (Sandbox Code Playgroud)

我希望所有网址看起来都与上面完全一样,但是可以通过:处理http://www.test.com/webapp/index.html

我还希望该页面处理以下URL :

http://www.test.com
http://www.test.com/contact
http://www.test.com/about
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?

常规SINGLE_PAGE HTACCESS

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

ale*_*lex 5

仅添加答案以供参考。

@Croises的通讯:

“相同(使用[QSA]而不是[QA]),但在webapp目录中”

为我工作。

“ .htaccess”必须位于子目录中。

示例工作“ .htaccess”:

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

唯一的区别是“ [QA,L]”与“ [QSA,L]”