我正在尝试在本地XAMPP服务器上运行Codeigniter项目,但连接被拒绝,找不到网站或域不存在

时间:2019-05-14 13:00:15

标签: php codeigniter xampp

我有一个Codeigniter项目,我想在本地XAMPP服务器上试用。如配置文件中所指定,项目的URL是“ https://maap:8890/”:

$config['base_url'] = 'https://maap:8890/';

真实的URL是“ http://127.0.0.1/maap/index.php”,我在.htaccess文件中使用mod_rewrite,如下所示:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

我首先尝试仅启动XAMPP并尝试网站。完整的URL(127.0.0.1/maap/index.php)已成功重定向到https://maap:8890/login,但是该站点仅显示DNS_PROBE_FINISHED_NXDOMAIN,因此我在Google上进行了大量搜索,发现可能必须设置虚拟主机。所以我做了如下:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\maap"
ServerName maap
<Directory "C:\xampp\htdocs\maap">
    Require all granted
</Directory>

这是我的httpd-vhosts.conf,这是我的主机文件:

127.0.0.1           maap

现在,如果我输入完整的URL,它只会显示404错误。如果后来尝试到达https://maap:8890/,则会收到连接被拒绝的错误消息。我在Chrome和Edge上尝试了所有这些方法,并尝试将虚拟主机的端口更改为443或8890,但没有任何帮助。 Codeigniter项目不是我的项目,我确定它可以在Mac上的Mamp上运行。很抱歉,如果我的问题看起来很愚蠢,或者我描述的东西不对,但是我真的是新手。我希望有人可以帮助我或给我任何其他有关我可以尝试的线索。如果有需要,我很乐意提供更多代码

1 个答案:

答案 0 :(得分:0)

我仍然不知道如何使用maap url,但我只是将baseurl更改为“ http://127.0.0.1/maap/”,并且一切正常。所以我想我并没有真正解决它,但是找到了解决我的问题的方法