Abzax Abzax - 1 year ago 183
Apache Configuration Question

How to remove index.php from URLs

Am wondering how to remove index.php from URLs, every link on my site has index.php in it, for e.g. example.com/index.php/contact-us.

Am using Drupal 8, my server is Apache and php version is 5.6, and am on Shared Hosting.

In the .htaccess file i tried to use

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

That removed the index.php but any new article wont show the images in the homepage(index.php)

then i tried to use

RewriteBase /
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

Same thing happened.

Please advice

Answer Source

Please take a look at the following Drupal 8 documentation: https://www.drupal.org/docs/8/configuring-clean-urls/enable-clean-urls

This should help you to enable clean URLs.

Additionally: You might want to check the following issue and comments for your problem: Enable Clean URLs

Extension: Try checking the src URL on your images (If they contain the index.php, if not it might be a permission misconfiguration)

Edit: Try this code in your .htaccess

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

On a side note: You might want to consider switching to PHP7 since active support for PHP5.6 will end soon. (Source)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download