Sam
Sam

Reputation: 141

.htaccess not working in digital ocean server

When I use the .htaccess as followed, I am getting The requested URL was not found on this server error. My configurations are as

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>

I changed /etc/apache2/apache2.conf from

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

To

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

The file /etc/apache2/mods-enabled/dir.conf as

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

I changed myapp\application\config\config.php as $config['index_page'] = ''; and $config['uri_protocol'] = 'REQUEST_URI';

And I have run the following commands in my digitalocean server

sudo a2enmod rewrite
sudo service apache2 reload

When I opening my_site in browser, after done all this I am getting the following message Not Found

If I remove the .htaccess and reset myapp\application\config\config.php as $config['index_page'] = 'index.php'; It is working. So pls help.

Upvotes: 1

Views: 2222

Answers (1)

Manoj Thakur
Manoj Thakur

Reputation: 75

It should be like this

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

Upvotes: 2

Related Questions