Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:50:03+00:00 2026-06-17T13:50:03+00:00

In my forum urls, there is index.php in it everywhere. I want to replace

  • 0

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”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:50:05+00:00Added an answer on June 17, 2026 at 1:50 pm

    You can use str_replace(). Like this:

    $new_url = str_replace('index.php', 'test/', $original_url);
    

    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:

    $pattern = '/index\.php/';
    $replacement = 'test/';
    $subject = 'http://yoursite.com/index.php?foo=bar';
    
    echo preg_replace($pattern, $replacement, $subject);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following URLs with the same content: http://www.mysite.com/forum/viewthread.php?thread_id=39&pid=1349 http://www.mysite.com/forum/viewthread.php?forum_id=2&thread_id=39 Which at the
I've got a website where URLs are rewritten in this format: http://www.example.co.uk/module/page/query/ http://www.example.co.uk/index.php?m=module&p=page&q=query Which
I'm often seeing sites there IDs in urls looks like this: http://battlelog.battlefield.com/bf3/forum/view/2811510711334022807/ How do
I have an .htaccess file that redirects all URLs to the index.php file with
According to this forum , SSIS only supports UTF-16 Little Endian flat files. Is
I have been finding myself doing URLs like this: $link = base_url('post') . '/'
I have a blog which generates URLs like: /article-name /my-article /other-article Then there is
Im currently using Code Igniter to have pretty URLs, and I have this system
I have URLs in the form of example.com/pages/page1 and /example.com/pages/page2 Is there an easy
I am trying to rewrite my urls to go from /controller/method to index.php?/controller/method, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.