![](/img/trans.png)
[英]XAMPP can connect via localhost:8080 but not via IP address / 127.0.0.1
[英].htaccess redirect XAMPP Dashboard (http://localhost:8080 ) or specific IP address (http://127.0.0.1:808080) to specific folder
我需要將具有特定IP地址的訪問者重定向到服務器中的特定文件夾。
我想http://127.0.0.1:8080重定向我http://127.0.0.1:8080/portfolio
但是,當我在瀏覽器中放置http:// localhost:8080或http://127.0.0.1:8080時 ,它會將我重定向到XAMPP Dashboard 。
我應該在哪里放置.htaccess
文件。 在htdocs
文件夾中還是其他地方?
如何將IP地址重定向到特定文件夾而不是XAMPP儀表板 ?
為什么不使用apache的虛擬主機,而不是搞亂.htaccess files
?
在Apache conf文件中,取消注釋http-vhosts.conf中所需的行。 然后使用以下內容編輯該文件:
<VirtualHost *:80>
DocumentRoot "/your/htdocs/sitename/public"
ServerName fakedomain.com
ErrorLog "path/to/error_log"
<Directory "/your/htdocs/sitename">
DirectoryIndex index.php
FallbackResource /index.php
Options -Indexes +FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
編輯之后,您需要編輯/etc/hosts
或c:\\windows\\system32\\drivers\\etc\\hosts
。 您所要做的就是像這樣添加fakedomain:
127.0.0.1 fakedomain.com
現在,當您重新啟動apachea和瀏覽器時,您應該能夠瀏覽到http://fakedomain.com
,它將轉到正確的項目。
注意:我的項目在我的主要入口index.php所在的位置有一個公用文件夾,這就是為什么您看到DocumentRoot的末尾帶有
/public
卻沒有Directory的原因。 如果您不只是調整適合自己的道路!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.