首页 > 解决方案 > 使用 SSL 为子域设置 .access

问题描述

我在 /public_html/assets/api/images/api.php 或https://www.example.org/assets/api/images/api.php的主机中有一个脚本

现在我正在尝试使用通过https://images.example.org访问的 .htaccess 对其进行别名

我在 /home/mydomain/assets/api/images 中创建了一个 .htaccess,我在其中放置了以下代码:

RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 

RewriteEngine On
RewriteBase /


RewriteRule ^(.*) api.php?category=$2&id=$3&type=$4&size=$5&file=$6 [NC,QSA]

.htaccess 将接收具有以下语法的 url:

https://www.example.org/assets/api/images/products/87/flyer/md/c4Nrlh_WyrrS-SBEFzwl.png _

但它不起作用。字符串传递了空值,我得到:

类别=&id=&type=&size=&file=

完整的值只会转到 $1 字符串,而不会拆分为 $2、$3、$4...

产品/87/flyer/md/c4Nrlh_WyrrS-SBEFzwl.png

任何人都可以帮我修复它吗?谢谢!

标签: apache.htaccess

解决方案


我让它工作了!

RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 

RewriteEngine On
RewriteBase /


RewriteRule ^([a-zA-Z_]+)/([0-9]+)/([a-zA-Z_]+)/([a-zA-Z]+)/([0-9a-zA-Z_-]+(\.(jpg|jpeg|png|gif))) api.php?&category=$1&id=$2&type=$3&size=$4&file=$5 [NC,QSA]

推荐阅读