.htaccess htaccess更改api的位置并重定向所有请求

.htaccess htaccess更改api的位置并重定向所有请求,.htaccess,.htaccess,我的api位于 /public_html/old/app/index.php 在此/old/app中有一个.htaccess文件,如下所示 Options -MultiViews -Indexes SetOutputFilter DEFLATE DirectoryIndex index.php <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^$ index.php [QSA,L] RewriteCond %{REQUE

我的api位于

/public_html/old/app/index.php
在此/old/app中有一个.htaccess文件,如下所示

Options -MultiViews -Indexes
SetOutputFilter DEFLATE
DirectoryIndex index.php

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

要将所有呼叫从/old/app文件夹重定向到/v1/app,我应该向上述htaccess添加什么内容?

您可以在目标中提供new
index.html
的完整路径:

SetOutputFilter DEFLATE
Options -MultiViews -Indexes
RewriteEngine On

RewriteRule ^$ /v1/app/index.html [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /v1/app/index.html [L]

谢谢,这在浏览器中工作正常,但在应用程序中引发错误:(浏览器与任何其他web客户端的工作方式相同。它只向服务器发送web请求。您收到了什么错误?状态为空的错误,没有响应:(,与cors不正确时得到的结果相同。那么它可能与重写无关。规则只能重写为正确的处理程序,rest应该在您使用的代码或框架中。事实上,它与重写无关!我联系了主机支持人员,他们回答说这是chmod问题,类似于文件夹必须是0755。他们修复了它,现在可以正常工作了。t阿努巴瓦汉克斯酒店
SetOutputFilter DEFLATE
Options -MultiViews -Indexes
RewriteEngine On

RewriteRule ^$ /v1/app/index.html [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /v1/app/index.html [L]