0

I have installed wordpress in the sub-directory /www/html/wordpress/ (and not at /www/html/) and the solution given here How to get rid of index.php didn't work on this server.

The solution suggests adding the following to .htaccess:

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

and changing to 'AllowOverride ALL' in apache configuration.

The solution worked for my other server where wordpress is installed at /www/html/ but not this one. Do you know why is that and how I can possibly fix it? (Apparently I should change the above code in .htaccess but I don't know how)

  • What do your URLs currently look like? What are your permalink settings set as? – bosco Mar 25 '17 at 4:17
-2

Login to your Wordpress Dashboard and Click Settings > Permalinks. Under Common Settings, Select Custom Structure and in the text field enter /%postname%/

Click Save Changes

The second step is creating an .htaccess file which is then uploaded into the root location of the Wordpress site.

The .htaccess file will contain the below rules:

RewriteEngine on
RewriteBase / 

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

#for wordpress with a directory of blogs
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^wordpress/(.*)$ wordpress/index.php/$1 [NC,L]
  • Thanks but the above code did not work for me! The pages without including index.php can't be loaded. – geek2000 Mar 25 '17 at 22:01
-2

Depending on your settings the default .htaccess entries would look exactly like your code (see below). If after activating one of the settings other than "default" in the WordPress Dashboard > Settings > Permalinks you still can't get rid of index.php that indicates the default WordPress entries aren't taking effect.

Are you sure that your .htaccess files are loaded when apache starts?
What does your Apache <virtualhost> look like for the directory WordPress is installed in?

Wordpress default .htaccess entry after activating permalinks

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

If all else fails you can try adding this code in your .htaccess file. This isn't really a solution but by adding this in your .htaccess file it might throw an error that points you to the source of the problem. Check your error log files.

# Force requests for index.php files to drop the index.php file filename
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(php)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(php)$ /$1 [R=301,L] 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.