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

  • Home
  • SEARCH
  • 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 877043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:32:26+00:00 2026-05-15T11:32:26+00:00

I’m running PHP on a shared Apache web server. I can edit the .htaccess

  • 0

I’m running PHP on a shared Apache web server. I can edit the .htaccess file.

I’m trying to simulate a file file structure that is not actually there. For example, I would like for the URL: www.Stackoverflow.com/jimwiggly to actually display www.StackOverflow.com/index.php?name=jimwiggly I got halfway there by editing my .htaccess file as per the instructions in this post: PHP: Serve pages without .php files in file structure:

RewriteEngine on
RewriteRule ^jimwiggly$ index.php?name=jimwiggly

This works nicely insofar as the URL bar still displays www.Stackoverflow.com/jimwiggly and the correct page loads, however, all of my relative links remain unchanged. I could go back in and insert <?php echo $_GET['name'];?> before each link, but it seems like there might be a better way than that. Additionally, I suspect my whole approach might be off, should I be going about this differently?

  • 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-05-15T11:32:27+00:00Added an answer on May 15, 2026 at 11:32 am

    I think the best way to do this is to adopt the MVC style url manipulation with the URI and not the params.

    In your htaccess use like:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        #Rewrite the URI if there is no file or folder
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    

    Then in your PHP Script you want to develop a small class to read the URI and split it into segments such as

    class URI
    {
       var $uri;
       var $segments = array();
    
       function __construct()
       {
          $this->uri = $_SERVER['REQUEST_URI'];
          $this->segments = explode('/',$this->uri);
       }
    
       function getSegment($id,$default = false)
       {
          $id = (int)($id - 1); //if you type 1 then it needs to be 0 as arrays are zerobased
          return isset($this->segments[$id]) ? $this->segments[$id] : $default;
       }
    }
    

    Use like

    http://mysite.com/posts/22/robert-pitt-shows-mvc-style-uri-access

    $Uri = new URI();
    
    echo $Uri->getSegment(1); //Would return 'posts'
    echo $Uri->getSegment(2); //Would return '22';
    echo $Uri->getSegment(3); //Would return 'robert-pitt-shows-mvc-style-uri-access'
    echo $Uri->getSegment(4); //Would return a boolean of false
    echo $Uri->getSegment(5,'fallback if not set'); //Would return 'fallback if not set'
    

    Now in MVC There usually like http://site.com/controller/method/param but in a non MVC Style application you can do http://site.com/action/sub-action/param

    Hope this helps you move forward with your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites 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.