【问题标题】:VirtualHost port 8080. apache 2.4 . removing index.php in htaccess虚拟主机端口 8080. apache 2.4 。删除 htaccess 中的 index.php
【发布时间】:2018-06-01 01:26:56
【问题描述】:

这是我的虚拟主机:

<VirtualHost *:8080>
   ServerAdmin webmaster@dummy-host.localhost:8080
   DocumentRoot "D:/test/testpage/"
   ServerName testpage
   ServerAlias testpage.localhost
   ErrorLog "logs/testpage-error.log"
   CustomLog "logs/testpage-access.log" common
</VirtualHost>

系统/主机

 127.0.0.1  testpage.localhost

xampp/apache/conf/中的httpd.conf

Listen 8080
ServerName localhost:8080

LoadModule rewrite_module modules/mod_rewrite.so

<Directory />
   AllowOverride All
   Require all granted
</Directory>

我在 testpage 文件夹中的 .htaccess 文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

在我的应用程序/config/config.php 中

$config['base_url'] = 'http://testpage.localhost:8080';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

我面临的唯一问题是 index.php,我可以访问我的其他页面,但它在 base_url() 和视图之间有 index.php。

【问题讨论】:

  • 将您的 .htaccess 文件放在项目文件夹中,而不是在应用程序文件夹中
  • 我的 .htaccess 在同一级别的应用程序文件夹中,而不是在应用程序文件夹内。

标签: php .htaccess codeigniter codeigniter-3


【解决方案1】:

我建议尝试以下 VirtualHost (vhost) 指令。

它将D:/test/testpage/testpage 定义为站点的公共根。 .htaccess 和 CodeIgniter 的 index.php 都应该在这个目录中。 我已经删除了ServerAlias - 你不需要它。 我已经为 vhost 目录添加了明确的指令

<VirtualHost *:8080>
   ServerAdmin webmaster@dummy-host.localhost:8080
   DocumentRoot D:/test/testpage
   ServerName testpage
   ErrorLog "logs/testpage-error.log"
   CustomLog "logs/testpage-access.log" common

   <Directory D:/test/testpage>
      Options -Indexes +FollowSymLinks
      AllowOverride All
      Require all granted
   </Directory>
</VirtualHost>

系统/主机应该是

127.0.0.1  testpage

因为您已将虚拟主机命名为“testpage”,所以以下内容应该可以工作。

$config['base_url'] = 'http://testpage/';

【讨论】:

猜你喜欢
  • 2016-05-02
  • 2019-07-17
  • 2014-11-10
  • 1970-01-01
  • 2018-11-06
  • 2017-04-16
  • 2013-07-21
  • 1970-01-01
  • 2014-12-28
相关资源
最近更新 更多