【发布时间】:2021-12-25 07:43:00
【问题描述】:
以下是我尝试过的现有 .htaccess 规则设置
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^api/([a-z]{1,3})/([0-9a-zA-Z]{1,15})$ api.php?ac=$2&type=$1 [L]
RewriteRule ^s/([0-9a-zA-Z]{1,15})$ init.php?ac=$1&type=s [L]
RewriteCond %{REQUEST_URI} !^.*\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ %{REQUEST_FILENAME}.php
我将几个域 exampleA.com 和 exampleB.com 停放在 example.com
我想重写下面的case
example.com/s -> error 404 page
example.com/s/ -> error 404 page
example.com/s/abc -> init.php?type=s&account=abc
example.com/api/s/abc -> api.php?type=s&account=abc
example.com 除外
exampleA.com -> init.php?type=d
exampleB.com -> init.php?type=d
exampleA.com/abc -> init.php?type=d&account=abc
exampleB.com/abc -> init.php?type=d&account=abc
exampleA.com/api/abc -> api.php?type=d&account=abc
exampleB.com/api/abc -> api.php?type=d&account=abc
如何编写 RewriteCond 和 RewriteRule 来存档?
【问题讨论】:
-
在使用提供的解决方案时,请确保您拥有子域的通用目录结构。
标签: apache .htaccess mod-rewrite