[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2013-06-14
2
Medium Priority
?
313 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

650 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