Solved

Correct PHP code for hidden frame-based redirection (sent from htaccess)

Posted on 2010-11-11
4
392 Views
Last Modified: 2012-06-21
Expanding on my original question, although the .htaccess redirect works, I'd like to redirect to a PHP document within the same domain and have it mask the redirection.

So, what I'd like to do is take:

RewriteRule ^t/([0-9]+)  http://otherdomain/tickets/$1  [R=301,NC]
RewriteRule ^e/([0-9]+)  http://otherdomain/entries/$1  [R=301,NC]

change them to

RewriteRule ^t/([0-9]+)  http://mydomain/rd.php?type=t&num=$1  [R=301,NC]
RewriteRule ^e/([0-9]+)  http://mydomain/rd.php?type=e&num=$1   [R=301,NC]

What I need is a working "rd.php" to handle a redirected request of this nature and then generate a frame-based redirect page sending the user to http://otherdomain/{type}/{num}

I have a version partially hacked together, but it's probably better than I refrain from posting and let someone whip one up in 30 seconds...

Thanks in advance!
Josh
0
Comment
Question by:joshky
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:virmaior
Comment Utility
i'm not sure what you mean by frame-based redirect...

do you mean:
(a) the frame causes the web browser to navigate to the other page (thereby closing the current page)?
(b) the frame opens the new page and remains framed within the other?


if you want the frame to cause a 301 redirect, then this will only affect the frame itself and not the entire page including the browser bar.
0
 

Author Comment

by:joshky
Comment Utility
Sorry about the confusion.  Basically, the HTML outside of the normal headers would be:

<frameset rows="100%,*" border="0">
  <frame src="http://otherdomain/tickets/$1" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>
0
 
LVL 20

Accepted Solution

by:
virmaior earned 500 total points
Comment Utility
<?php
echo '<frameset rows="100%,*" border="0">
  <frame src="http://otherdomain/tickets/'  . htmlentities($_GET['type']).  '/' . htmlentities($_GET['num']) . '" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>';

?>
0
 

Author Comment

by:joshky
Comment Utility
Worked great... Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 count occurrences of each item in an array.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now