我正在为我的组织设置网址缩短服务。我想将缩短的 url重写为我的 index.php 文件,但将请求重定向到我的主网站的根目录,即:
请求:short.domain.tld/abc
用户看到:short.domain.tld/abc
提供的页面:short.domain.tld/index.php?code=abc
请求:short.domain.tld/
用户看到:website.domain.tld
提供的页面:website.domain.tld(在我的网站服务器上)
我的 .htaccess 文件目前是:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^/(.*)$ index.php?code=$1 [L]
RewriteRule ^.*$ http://website.domain.tld/
我不确定如何区分对子目录的请求和对域根的请求。