In my forum urls, there is “index.php” in it everywhere. I want to replace it with “test”. In my PHP files, I have this line:
// Makes it easier to refer to things this way.
$scripturl = $boardurl . '/index.php';
I tried just changing it to:
// Makes it easier to refer to things this way.
$scripturl = $boardurl . '/test';
However, that returned 404 errors. I was told that I needed to use preg_replace to make that happen. I looked at the PHP Manual, and it says I need a pattern, replacement, and a subject. I’m confused about the subject part.
I tried this, but no prevail:
// Makes it easier to refer to things this way.
$scripturl = $boardurl . preg_replace('/index.php','/test','?');
Here is an example URL: “domain.com/index.php?node=forum”
I want it to look like: “domain.com/test?node=forum”
You can use
str_replace(). Like this:Note that
preg_replace()would do the job too but it is more complex (and powerful). str_replace() fits in this case.Just for your info, the subject param for str_replace is the orginal string, in your example the url with ‘index.php’ in it. Your example would look like: