我正在嘗試使用 XAMP 作為我的本地主機來設定本地開發環境。
我的問題是,我將我的專案放在 htdocs 檔案夾的子檔案夾中。
這意味著我的目錄結構是:
localhost/myProject/index.php
但是,這也意味著我的專案的“根”是“localhost”,而不是我想要的“localhost/myProject”。
關于我如何解決這個問題的任何建議?
為了清楚起見,我想修復它的原因是我使用 CakePHP,它的結構類似于:“root/controller/action”,但由于它放在 htdocs 的檔案夾中,所以我訪問它的方式是:“localhost /myProject/controller/action” - 問題是,它認為“myProject”是要查找的控制器。這就是我要解決的問題。如果您有任何想法,請為上帝的愛幫助我
HTACCESS 更新
根.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
RewriteBase /bakesystem
#Rewrite everything to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
網路根 .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
#Rewrite everything to https - disabled on test
#RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
uj5u.com熱心網友回復:
您在根 .htaccess 中有兩次重寫引擎。回傳到您的默認 htaccess(如果您沒有備份副本,請從新的 cakephp 專案中獲取)。
然后嘗試在您的組態檔(/app/Config/core.php)中設定專案根目錄
配置::write('App.fullBaseUrl', 'http://example.com');
將此更改為您的基本網址并更新我..
uj5u.com熱心網友回復:
這沒什么可“修復”的,因為這是預期的行為。對于這種情況,您可以創建 VirtualHosts,您可以在其中告訴 apache 您的專案的 DocumentRoot 在哪里,鏈接到瀏覽器中的“唯一”主機名。
這是一個如何使用 Windows 作為作業系統的示例。 如何在 XAMPP (Windows) 上設定 Apache 虛擬主機
下面是一個簡單的例子,這樣一個虛擬主機的樣子:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/xampp/htdocs/example
ServerName example.local
SetEnv APPLICATION_ENV development
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
</VirtualHost>
您還想編輯您的主機檔案,但所有內容都在我鏈接的主題中進行了解釋。
根據您的作業系統,我的路徑有所不同。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/510597.html
標籤:php阿帕奇本地主机
