404 not found , the requested URL <<url name>> not found on this server in wordpress

吃可爱长大的小学妹 提交于 2020-01-12 15:27:36

问题


I recently installed wordpress , I am facing issues when I try to change the permalinks format ,

when I change the permalink from default to day and time

 Default    http://127.0.0.1/?p=123
 Day and name   http://127.0.0.1/2015/03/16/sample-post/ 

the link generated does't working , it gives the same error 404 all the time ,

 The requested URL /2015/03/16/post-5-problem/ was not found on this server.

But when the permalink type was default this works perfectly.

I found some solutions which are

sudo a2enmod rewrite

Module rewrite already enabled

Another solution is to change the mode permissions of .htaccess file to 666(giving write permission to wordpress of .htaccess file) before change the permalink from default to some other type ,

sudo chmod 666 /address_of_.htaccess 

i checked the .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

but the above seems to be correct , the above included by the wordpress itself

Both the solutions does't seem to work , is there any other thing do I have to change to enable the permalink options ?


回答1:


If it is a fresh install of web server it is possible that .htaccess rules are not allowed by default. To fix that, edit you httpd.conf (usually it is in /etc/apache2), find

<Directory "path/to/your/document/root">    
    # ....

     AllowOverride None

    # ....

</Directory>

and change

AllowOverride None

to

AllowOverride All

Then restart your web server and try again.




回答2:


Reset your desired permalink from wordpress admin area and add this code in htaccess:

# BEGIN WordPress

<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Now, check with blog posts and pages.

Thanks,




回答3:


You are receiving this error because your webserver cannot find the file, and it's not passing the request to Wordpress.

You need to add rewrite rules for your Wordpress, and instructions for that depend on your webserver software (Apache, nginx, etc).

Example with nginx:

location / {
       try_files $uri $uri/ /index.php?$args;
}

Which literally means: try to open "/2015/03/16/post-5-problem/" in filesystem first, if it doesn't exist try to add a slash, if that doesn't help pass the request to index.php (which is Wordpress main file) with the arguments.

Enabling rewrite module is not enough, you have to add rewrite rule(s).



来源:https://stackoverflow.com/questions/29074376/404-not-found-the-requested-url-url-name-not-found-on-this-server-in-wordp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!