[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

mod_rewrite with query string

Posted on 2013-01-17
4
Medium Priority
?
383 Views
Last Modified: 2013-01-18
I currently have a site that uses URLs like the following:
www.mysite.com/index.php?Page=page1
www.mysite.com/?Page=page1

I would like to be able to use URLs like the following:
www.mysite.com/page1

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
0
Comment
Question by:LouSch7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
arober11 earned 2000 total points
ID: 38788529
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.
0
 
LVL 3

Author Comment

by:LouSch7
ID: 38788639
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.

<?php
	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?
0
 
LVL 26

Expert Comment

by:arober11
ID: 38792291
Not unless you provide the URL your trying to access and whether that file physically exists on the server, and in the specified location.
0
 
LVL 3

Author Comment

by:LouSch7
ID: 38792296
The solution was to get the URL instead of the page from the server variables. All seems to be working now, thank you!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question