• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

mod_rewrite with query string

I currently have a site that uses URLs like the following:

I would like to be able to use URLs like the following:

I am using GoDaddy and have full access to my .htaccess file.  I have RewriteEngine On however, I do not know where to go next with this.

Thank you
  • 2
  • 2
1 Solution
The following may be a good start:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$  /index.php?Page=$1 [L]

Open in new window

If you need an explanation of the rule the the following article  is a good place to start.
LouSch7Author Commented:
I have added that to my .htaccess file however, I am now receiving an error message that says it was unable to load missing.html.php.  I use the below code in my header file in order to determine what file to include in the body of the site.

	If ($_GET['Page'] == ''){
		$myPageTitle = 'home';
	} else {
		$myPageTitle = $_GET['Page'];
	$Page = $myPageTitle . ".php";

Open in new window

And here is where the variable is used

<?php include $Page; ?>

Open in new window

Any thoughts?
Not unless you provide the URL your trying to access and whether that file physically exists on the server, and in the specified location.
LouSch7Author Commented:
The solution was to get the URL instead of the page from the server variables. All seems to be working now, thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now