permanent links are working but /%postname%/ not - wordpress

Default permanent links are working fine, but when I try to change it to /%postname%/ or any other type, It is showing the following error.
Anyone have an idea why it is happening..?
Server : ubuntu 20.04

Add the following code in your .htaccess file:
# 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

Related

Website giving me 500 internal server error - is it .htaccess error?

My website is giving a 500 internal server error when I click on any category header menu, but the homepage is loading fine. I did some troubleshooting, but from my understanding it narrows down to .htaccess rewrite rules.
Here is my .htaccess code, I need help with this please:
My .htaccess code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
You can replace your .htaccess file with this:
# 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
Troubleshooting 500 internal server error
Go FTP into your website
Open the file named wp-config.php
Find the line where you see define('WP_DEBUG', false);
Change false to true and save the file
Now you check..

Wordpress not redirecting properly (Forbidden)

At some point I changed my Wordpress URL under Settings -> General. This created a lot of problems that are mostly fixed. However, my site's Url is "example.com/guiacentros/" and that works, but when users wrote "example.com" it also used to work, and now they get a "Forbidden - You don't have permission to access / on this server". Is this an error with the htacces file? This is the current htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /guiacentros/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /guiacentros/index.php [L]
</IfModule>
# END WordPress
I'm a bit confused because there's a second htaccess file one level above, that looks like this:
# 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
I'm not sure why there's two, but I remember adding the second one fixed some issues.

404 error with a 2nd Wordpress install in a sub-directory

Lots of topics similar to this one but nothing seems to have worked so far. First time posting on this site - apologies if I miss off anything vital!!
Current site is - http://www.mansfordwebdesign.com - working fine but I want a 2nd Wordpress install as a development environment. I've created a subfolder called 'ilead' via my FTP and uploaded the Wordpress files.
When I go to http://www.mansfordwebdesign.com/ilead/wp-activate.php or any other related Wordpress file I get a 404 error.
Both sites have a .htaccess file - the first is -
`# 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`
The second is
`# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ilead/index.php [L]
</IfModule>
# END WordPress`
Is something wrong in these files or could it be anything to do with my WHM or CPanel controls??
Any thoughts or suggestions are appreciated.
Try changing the RewriteBase line to what is below for the subfolder..
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ilead/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ilead/index.php [L]
</IfModule>
# END WordPress

Wordpress returns 404 on existing file

I have the following stucture:
Wordpress installed in root, and an /api/api.php file manually created
When I go to www.example.com/api/api.php I get a 404
This is my .htaccess in the root folder:
Options +FollowSymLinks
RewriteRule ^api/api\.php$ - [L]
# 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
I expect this should have let requests to /api/api.php through unmolested.
Also, I tried putting in a .htaccess file in /api with just
# disable the rewrite engine
RewriteEngine off
but I am still getting a 404 error despite this.
The rest of the site works fine, and I have tried disabling all WP plugins just in case.
try change your permalink from admin panel or if you have an IIS7 server then your permalink should be like %postname%index.php.
and also try this .htaccess code and instead of 'example' write your site base path name
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /example/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example/index.php [L]

All my pages apart from index lead to a 404 page

My settings for permalinks: default : /?p=123 works but if I switch to by post name All pages stop working and just go to a 404
Check your permalink settings and see if you have enable rewriting in your .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>

Resources