【发布时间】:2017-03-06 09:47:20
【问题描述】:
不确定我想要的是否可以完成,我发现这里有很多很接近的东西,但不完全在那里。我想要/需要将根 URL (/) 重定向到在它自己的 web 根目录中的子文件夹中运行的 wordpress 站点。使用:
RewriteEngine on
# our root gets redirected to wordpress
RedirectMatch ^/$ http://mysubdomain.com
...效果很好。然后对于除根以外的任何东西(例如 example.com/somepath),我需要根中的 index.html 来处理它。这是带有自己的路由器的 Vue JS 应用程序的入口点。我试过了:
RewriteEngine on
# our root gets redirected to wordpress
RedirectMatch ^/$ http://mysubdomain.com
# anything else load our app (index.html in the web root)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://example.com/$1 [L,QSA]
...但这会导致 Bowser 中出现过多的重定向错误。我试过了:
RewriteEngine on
# our root gets redirected to wordpress
RedirectMatch ^/$ http://mysubdomain.com
# anything else load our app (index.html in the web root)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.html [L,QSA]
... 这几乎可以工作,除了路径中有一个文字 index.html ,而不仅仅是 urls 路径。目标是让根路径通过 web 根目录中的 hte Vue JS 应用程序(我认为是通过 index.html)进入该文字路径。因此,如果访问http://example.com/somepath,浏览器位置应该是通过 Vue JS 路由器的路径进程。
希望这是有道理的。有什么想法或想法吗?我也知道我可以重定向到其中包含 Vue JS 应用程序的子文件夹,但这不是客户想要的,除非该子文件夹可以从 URL 中排除。
TIA!
【问题讨论】:
标签: javascript apache .htaccess