?
Solved

.htaccess check for 'page=' in page URL?

Posted on 2013-06-14
2
Medium Priority
?
312 Views
Last Modified: 2013-06-15
0
Comment
Question by:sabecs
[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 Comments
 
LVL 30

Expert Comment

by:Randy Downs
ID: 39249515
You can conditionally redirect as in the example below. Once the conditions are met the files are dealt with via a script. Hope this helps.


#Condionally redirect old  pages via script if not the index.html or state 
RewriteCond %{REQUEST_URI} !^/venues/index\.html$  [NC]
RewriteCond %{REQUEST_URI} !^/venues/states/.*$  [NC]
RewriteRule ^venues/(.*) scripts/redirect-v.php?d=$1&%{QUERY_STRING} [L]
RewriteRule ^venues/states/(.*) scripts/redirect-state.php?d=$1&%{QUERY_STRING} [L]

Open in new window


redirect-v.php
<?
ob_start();

// Redirect old links
$file = $_GET['d'];
$file = strtolower($file); 

// Catch special cases that had -and- substituted for &
$file = str_replace("-and-", "___", $file);
$file = str_replace("-", "_", $file);

// Catch old pages that end with .htm and .shtml
//$file = str_replace(".htm", ".html", $file);
$file = str_replace(".shtml", ".html", $file);
//$file = str_replace(".php", ".html", $file);

$new_url = 'http://www.site.com/venue/' . $file;
//echo "<br /> New URL is " . $new_url ;

// redirect
$ext = substr(($file), -4); 
//echo "<br /> Extension is " . $ext ;

if ($ext=="html")
{
//	echo "<br />  Redirect old page. "; 
//	echo "<br /> URL ends in html. Redirect to ". $new_url; 
	header("HTTP/1.1 301 Moved Permanently");
	header('Location: ' . $new_url);
}
else {
	$new_url=$new_url.'_tickets.html';
//	echo "<br />  Redirect page. "; 
//	echo "<br /> no extension - Append _tickets.html to url. Redirect to ". $new_url; 
	header("HTTP/1.1 301 Moved Permanently");
	header('Location: ' . $new_url);
}


?>

Open in new window

0
 
LVL 30

Accepted Solution

by:
Randy Downs earned 2000 total points
ID: 39249520
In my script I am checking for files that ended in .htm and .shtml. I then replaced those with .html. Then I back up 4 characters (i.e. html) and Append _tickets.html to the file.

You can do something similar keying on the text "page".
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 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