Mengatasi htaccess Not Working di Laragon

Mengatasi htaccess Not Working di Laragon

Sobatcoding.com - Mengatasi htaccess Not Working di Laragon

Artikel kali ini admin akan berbagi pengalaman saat setting htaccess di CodeIgniter untuk menghilangkan index.php tapi tidak bekerja di Laragon. Biasanya untuk menghilangkan index.php di Codeigniter 3 kita bisa lakukan dengan membuat file .htaccess dengan memasukkan kode sebagai berikut:

<IfModule mod_rewrite.c>
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]
    
    Options All -Indexes
</IfModule>

 

Tapi hal itu tidak bekerja sama sekali, index.php tetap muncul di URL. Setelah browsing ke sana kemari, akhirnya admin menemukan solusinya. Berikut langkah-langkah untuk mengatasi htaccess tidak bekerja di laragon:

  1. Buka file httpd.conf melalui text editor yang ada di folder root laragon\bin\apache\httpd-{versi apache yang sedang digunakan}\conf\.
  2. Perhatikan line sekitar 251 sampai dengan 278. Disana terdapat script seperti berikut:
    DocumentRoot "C:/laragon/www"
    <Directory "C:/laragon/www">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks Includes ExecCGI
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   AllowOverride FileInfo AuthConfig Limit
        #
        AllowOverride None
    
        #
        # Controls who can get stuff from this server.
        #
        Require all granted
    </Directory>​
  3. Ubah AllowOverride None menjadi AllowOverride All
  4. Restart Laragon Server

 

Sekian tutorial kali ini dan semoga bermanfaat.

Jika teman-teman memiliki pertanyaan atau saran mengenai artikel ini, jangan ragu untuk meninggalkan komentar pada form di bawah ini.