Search code examples
wordpress.htaccesscomposer-phppermalinks

How to remove 'index.php' from permalinks [WordPress on Composer]


I have local server, on which I'm running WordPress with Composer.

After database migration from my local to AWS RDS, the permalinks changed it's behaviour: now there's 'index.php' in the beginning of tags, like:

http://example.com/index.php/name-of-page

Also, in the wp-admin->Settings->Permalinks the structure is custom now:

/index.php/%year%/%monthnum%/%day%/%postname%/

Details about my local server:

  • Xubuntu 18
  • Apache2
  • AllowOverride All for both / and var/www/
  • it's on Composer, with custom dir (wp-content is seperated from wp core)
  • .htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /project/public/wp/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /project/public/wp/index.php [L]
    </IfModule>
    
    # END WordPress
    

What I have tried:

http://dejanjanosevic.info/remove-index-php-permalink-in-wordpress/

http://derekmolloy.ie/remove-index-php-from-your-wordpress-url/

  • updating permalinks
  • updating composer
  • selling my soul to Satan

What are the results?

Modyfying .htaccess has no effect - just ends in 404, the only links that work are still the ones that include /index.php/. Updating permalinks from WordPress has same result.

I'm running out of ideas here.


Solution

  • I've got it.

    For anyone looking for a solution to the same problem, here's guide:

    1. Change permalink settings in wp-admin to pretty permalinks
    2. Install mod_rewrite module in apache
    3. The most important part, in etc/apache/apache2.conf (NOTE THAT YOU MUST CHANGE THE NAME OF FOLDER):

      <Directory />
          Options FollowSymLinks
          AllowOverride All
          Require all denied
       </Directory>
      
       <Directory /usr/share>
          AllowOverride None
          Require all granted
       </Directory>
      
       <Directory /var/www/>
          Options Indexes FollowSymLinks
          AllowOverride All
          Require all granted
       </Directory>
      
       #<Directory /srv/>
       #  Options Indexes FollowSymLinks
       #  AllowOverride None
       #  Require all granted
       #</Directory>
      
       <Directory "/var/www/html/NAME_OF_YOUR_PROJECT_FOLDER">
       Options FollowSymLinks
       AllowOverride All
       </Directory>*
      
      1. Restart apache