.htaccess删除子目录中的公用文件夹和index.php
我正在构建一个API,它被划分在子文件夹中。此api的第一个版本位于api.com/v1中,下一个版本是第四个版本,位于/v4中 版本一没有使用任何框架,只是纯PHP。api的第4版使用Laravel作为基础。从而产生一个公共文件夹。我不希望API URL像“API.com/v4/public/entry” 使用提供的.htaccess从URL中过滤index.php效果很好,但我没有让它过滤掉公用文件夹和index.php文件,同时将v4子目录保留在URL中 我不确定这是否可能 因此,api.com/v4/img/banner.png应该链接到api.com/v4/public/img/banner.png。 api.com/v4/gis/layer1.xml应该链接到api.com/v4/public/index.php/gis/layer1.xml 到目前为止,我的.htaccess文件位于v4文件夹中。位于公用文件夹中的.htaccess文件的修改版本,用于从URL中筛选出“index.php”.htaccess删除子目录中的公用文件夹和index.php,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我正在构建一个API,它被划分在子文件夹中。此api的第一个版本位于api.com/v1中,下一个版本是第四个版本,位于/v4中 版本一没有使用任何框架,只是纯PHP。api的第4版使用Laravel作为基础。从而产生一个公共文件夹。我不希望API URL像“API.com/v4/public/entry” 使用提供的.htaccess从URL中过滤index.php效果很好,但我没有让它过滤掉公用文件夹和index.php文件,同时将v4子目录保留在URL中 我不确定这是否可能 因此,api.
RewriteEngine On
# add basic auth support
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}public/index.php [NC,L]
包括/gis/的重写应该包括index.php/gis吗?当然可以?你能澄清什么不适合你吗?如果存在,也显示/v4/public/.htaccess。我从公用文件夹中删除了.htaccess文件,并在v4文件夹中使用了这个文件。现在控制器中的URI提交槽不正确,例如:v4/gis/layer1而不是gis/layer1。css文件也没有正确加载。