【问题标题】:.htaccess not working in digital ocean server.htaccess 在数字海洋服务器中不起作用
【发布时间】:2020-07-02 21:58:08
【问题描述】:

当我使用 .htaccess 时,我得到The requested URL was not found on this server 错误。我的配置如下

Digitalocean:var/www/html/my_site/.htaccess as

<IfModule mod_rewrite.c>
  # Rules to serve URLs which point to files directly
  # ----------
  RewriteEngine On
  RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

我更改了 /etc/apache2/apache2.conf 来自

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

文件/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>
   DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

我将 myapp\application\config\config.php 更改为 $config['index_page'] = '';$config['uri_protocol'] = 'REQUEST_URI';

我已经在我的 digitalocean 服务器中运行了以下命令

sudo a2enmod rewrite
sudo service apache2 reload

当我在浏览器中打开 my_site 时,完成所有这些操作后,我收到以下消息

如果我删除 .htaccess 并将 myapp\application\config\config.php 重置为 $config['index_page'] = 'index.php'; 它正在工作。所以请帮忙。

【问题讨论】:

    标签: php apache .htaccess codeigniter


    【解决方案1】:

    应该是这样的

    <Directory /var/www/html/my_site/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    

    【讨论】:

      猜你喜欢
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 2017-12-03
      • 1970-01-01
      • 2019-06-14
      • 2020-12-28
      相关资源
      最近更新 更多