0

i have changed the wordpress custom structure permalink to /%post_id%/%postname%/ and get this error :

404 Not Found The requested URL /mysite/blog/1/hello-world/ was not found on this server.

  • wordpress version 3.1.7
  • site address: localhost/mysite/blog

i'v changed this function in misc.php and saw the error again!

function got_mod_rewrite() {
    //$got_rewrite = apache_mod_loaded('mod_rewrite', true); //old line with false negative;
    $got_rewrite = true;//force the response to true as we know mod_rewite is installed;
    return apply_filters('got_rewrite', $got_rewrite);
}
1
  • You should never change core files in WordPress. The line in misc.php that you commented out will return TRUE by default, which means that, for some reason, apache_mod_loaded() doesn't think that mod_rewrite is installed. Double-check your server config.
    – Pat J
    Sep 22, 2014 at 22:31

2 Answers 2

1

Mehdi, it's common problem, as Apache server is not set by this way by default. Your problem can be solved with some very simple steps (simply quoting Samuel B):

If you want to use permalinks, you will need to make a change inside another file: apache > Conf and find the file httpd.conf. Open that in a text editor. Use the search facility in the editor to find "rewrite". The line you need looks like this:

#LoadModule rewrite_module modules/mod_rewrite.so

You need to take away the hash sign so it looks like this

LoadModule rewrite_module modules/mod_rewrite.so

Now just save the file.

Reference: WordPress Support - Answer by Samuel B

And a warning:

REMEMBER:
NEVER EVER EDIT A CORE WORDPRESS FILE, IT'LL SIMPLY MAKE YOUR WP BUGGY.

0
0

I wanted to use Custom Structure permalinks like this: www.example.com/blog/post/%post_id%/%postname%/

But just putting this /blog/post/%post_id%/%postname%/ in the custom structure resulted in 404 error.

I was able to resolve this issue by putting this in the custom structure field after reading some articles & trial n error: /index.php/blog/post/%post_id%/%postname%/ .

I use nginx.

1
  • Glad that worked, but that shouldn't be necessary I'd have thought? Your web server rewrite rules should remove the index.php (unless you want it there?)
    – Rup
    Nov 1, 2021 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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