Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Permalinks only work with index.php in the URL

When I try to change my WordPress Permalink settings, links to posts and pages return a 404 page. I have found the only way to get them to work is to either use Plain permalinks or to include /index.php/ in my permalink url, like domain.com/index.php/postname. How can I get them to work without index.php being part of the URL?

My .htaccess is below, and I have also used the .htaccess suggested at https://wordpress.org/support/article/using-permalinks/#creating-and-editing-htaccess, but changes to the permalinks puts the code below back into the htaccess file. Mod_rewrite is enabled on my Apache server.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
like image 622
user2165827 Avatar asked Jan 23 '26 17:01

user2165827


1 Answers

  1. Change permalink settings in wp-admin to 'PLAIN' permalinks
  2. Install mod_rewrite module in apache (ensure using php_info that its enabled)
  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"> --> Edit this part
 Options FollowSymLinks
 AllowOverride All  -->make sure its ALL
 </Directory>
  1. Re-enabled post based or any other permalink
like image 154
PanDe Avatar answered Jan 26 '26 20:01

PanDe