我剛剛使用 XAMPP 啟動了一個網站,大部分情況下一切正常。但是,當我輸入網址“www.mysite.com”時,它會啟動該網站,但網址為“www.mysite.com/website”。“網站”是我的文件所在文件夾的名稱。如何從地址欄中刪除“/網站”?.htaccess 文件RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME}\.php -fRewriteRule ^(.*)$ $1.php [NC,L]RewriteRule ^$ index.php [L]RewriteRule ^([a-zA-Z0-9]+)?$ user-profile.php?user_username=$1 [NC,L]XAMPP 文件夾中 htdocs 文件夾中的 index.php 文件<?php if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/website/'); exit;?>你可能會說我對此很陌生,但我到處都找過,但我不知道如何解決它。任何幫助表示贊賞。
2 回答

動漫人物
TA貢獻1815條經驗 獲得超10個贊
您的索引指向網站目錄。
改變
header('Location: '.$uri.'/website/');
只是
header('Location: '.$uri);
最好直接在 .htaccess 中檢查和調整 httpS,這樣您就不必依賴 index.php 來調整正在使用的協議。

慕沐林林
TA貢獻2016條經驗 獲得超9個贊
這不是 PHP 處理的事情。這是一個網絡服務器工作。只需在 apache 中使用 ServerName www.mysite.com創建 VirtualHost并添加您的 DocumentRoot /path_to_htdocs/website。像這樣的東西:
<VirtualHost?*:80> ????????DocumentRoot?"/path_to_htdocs/website" ????????ServerName?www.mysite.com </VirtualHost> <Directory?"/path_to_htdocs/website"> ????????AllowOverride?All ????????Options?FollowSymLinks?MultiViews?ExecCGI ????????Require?all?granted </Directory>
- 2 回答
- 0 關注
- 167 瀏覽
添加回答
舉報
0/150
提交
取消