0

In my functions file, I have a function that re-writes the URL into the name of page or post from https://example.com/index.php?page=faq into https://example.com/faq.

Problem is, it's not working. If I use it, all pages and posts turns into this:

Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

This is the code I am using to re-write. Is the problem within this or what am I'm doing wrong? Using PHP 8.

function url($url) {
if (rewrite_url) {
$url = preg_replace('/\&(.*?)\=/', '/', str_replace(['index.php?page=', 'index.php'], '', $url));
}
return base_url . $url;
}
  • 1
    https://stackoverflow.com/questions/16388959/url-rewriting-with-php You can refer this – Mai Truong Dec 31 '21 at 04:57
  • This code merely generates the link in the style you define. Is your webserver actually configured to accept those urls and does it feed them to your PHP file ? – Raxi Dec 31 '21 at 04:58

0 Answers0