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 8453861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:52:16+00:00 2026-06-10T11:52:16+00:00

So I just started working with Apache’s mod_rewrite module and I’ve run into a

  • 0

So I just started working with Apache’s mod_rewrite module and I’ve run into a problem I can’t seem to figure out. What I want is to have the address bar display clean URLs either when a user manually types in the URL or when the page is linked to. Right now I get clean URLs when they’re typed in but the query string still shows up in the address bar when the page is linked to. For example:

Typing in, myDomain.com/first takes me the page at myDomain.com/index.php?url=first and displays myDomain.com/first in the address bar.

But, when clicking a link like href=”index.php?url=first”. The address bar displays myDomain.com/index.php?url=first when I want it to display myDomain.com/first.

Here is my .htaccess file located in the same folder as my index file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_\-]+)/?$ index.php?url=$1 [NC,L]
</IfModule>

Here is my index file:

<?php
define('ROOT_DIR', dirname(__FILE__) . '/'); // Define the root directory for use in includes 
require_once (ROOT_DIR . 'library/bootstrap.php');

$url = strtolower($_GET['url']);

include(ROOT_DIR . 'views/headerView.php');

switch($url)
{
    case "first": include(ROOT_DIR . 'views/firstPageView.php');
        break;
    case "second": include(ROOT_DIR . 'views/secondPageView.php');
        break;
    default: include(ROOT_DIR . 'views/homeView.php');
} 

include 'views/footerView.php';
?>

And here is homeView.php:

<p>This is the home page.</p>
<p>To the first page. <a href="index.php?url=first">First Page</a></p>
<p>To the second page. <a href="index.php?url=second">Second Page</a></p>

Any advice or help on my linking problem would be greatly appreciated, thank you in advance.

  • 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-10T11:52:18+00:00Added an answer on June 10, 2026 at 11:52 am

    But, when clicking a link like href=”index.php?url=first”. The address
    bar displays myDomain.com/index.php?url=first when I want it to
    display myDomain.com/first.

    You’ll have to link to the “clean” URL. Remember, you’re not redirecting here. You’re rewriting! That mean’s you’ll have to change this:

    <p>This is the home page.</p>
    <p>To the first page. <a href="index.php?url=first">First Page</a></p>
    <p>To the second page. <a href="index.php?url=second">Second Page</a></p>
    

    To something like this:

    <p>This is the home page.</p>
    <p>To the first page. <a href="/url/first">First Page</a></p>
    <p>To the second page. <a href="/url/second">Second Page</a></p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started working with android and ran into a small problem. I am have
Just started working with .NET and MVC(1). I'm having a problem wherein in my
I just started having a problem where Apache will automatically restart after every few
I just started working with SSRS, so this question might seem silly. Anyway, for
I just started working on a new project and I can't set the build
I just started working on a project that will run on google app engine
I just started working with Javascript and I ran into an error with Visual
I just started working on a new Eclipse Android project and want to make
So I just started messing around with Apache's rewrite module and would like to
Just started working with Mercurial a few days ago and there's something I don't

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.