正如标题所示,我希望我的网址是:
到目前为止我所拥有的:
RewriteEngine On
# Handle Front Controller...
RewriteCond %{HTTP_HOST} ^api\.(.*)
RewriteRule ^ api.php [L]
# Handle Front Controller...
RewriteCond %{HTTP_HOST} ^admin\.(.*)
RewriteRule ^ admin.php [L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ website.php [L]
这确保当我输入:admin.localhost时,加载文件admin.php。 api.localhost也是如此。普通的localhost加载website.php文件。这里没问题。现在,我如何实现友好的网址?而且,当涉及到https时,我知道它不可能是localhost(或者也许是,我不知道),但是我有一个网站用ssl我想用它。
答案 0 :(得分:0)
通过一些修补,我找到了解决方案。
更新以反映我的评论:
RewriteEngine On
#Remove the comments below to enable enforcing HTTPS
#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Handle Front Controller...
RewriteCond %{HTTP_HOST} ^api\.(.*)
RewriteRule ^(.*)$ api.php?url=$1 [QSA,L]
# Handle Front Controller...
RewriteCond %{HTTP_HOST} ^admin\.(.*)
RewriteRule ^(.*)$ admin.php?url=$1 [QSA,L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ website.php?url=$1 [QSA,L]