Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 23rd, 2008, 02:22 PM
driz driz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: top 0; left: 0;
Posts: 67 driz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 19 m
Reputation Power: 5
Question Redirect everything under a dir to one page, except if linked from that page..

Hi all,

I am trying and trying, but in the end need your help..
I would like to create an htaccess file to do the following:

Code:
- Redirect everything in and under the directory /content/
- except if it is linked by the frameset /index.php
- to the /index.php?f=$1


I have tried to accomplish this with the following htacces:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/index.php$
RewriteCond %{REQUEST_URI} ^/content/$
RewriteRule ^(.*)$ http://www.domain.com/index.php?f=$1 [R=301,L]


Somehow, it doesn't work (it does not redirect). I appreciate any help with this or direction towards the solution. :-)

Last edited by driz : April 24th, 2008 at 02:31 PM. Reason: Just anonimized the url :-)

Reply With Quote
  #2  
Old April 24th, 2008, 02:21 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,124 jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 10 h 58 m 38 sec
Reputation Power: 717
Would it be possible to reword your explanation and include the <frameset> HTML and how it all ties together?
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #3  
Old April 24th, 2008, 02:30 PM
driz driz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: top 0; left: 0;
Posts: 67 driz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 19 m
Reputation Power: 5
Quote:
Originally Posted by jharnois
Would it be possible to reword your explanation and include the <frameset> HTML and how it all ties together?


Hi Jeremy,

Let me explain what every rule in my htaccess should do:

Code:
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/index.php$

Exclude all requests that are linked by the frameset /index.php

Code:
RewriteCond %{REQUEST_URI} ^/content/$

Include everything in and under the directory /content/

Code:
RewriteRule ^(.*)$ http://www.domain.com/index.php?f=$1 [R=301,L]

Redirect all requests to /index.php?f=$1 where $1 contains everything after www.domain.com

Hope that makes it more clear... Here's the code for the frameset. Well, it's not really a frameset, but it has iframes. Please find the relevant code below:

Code:
<div id="titel_container">
<div id="titel">
<iframe name="titel" src="titel.php" width="247" height="60" frameborder="0"></iframe></div>
</div>
<div id="content">
<iframe name="content" src="/content/<?= $_GET[f]; ?>" width="572" height="233" frameborder="0"></iframe>
</div>


In the end I woulde like to accomplish that every request to e.g.

www.domain.com/content/great-content/bla/bla
www.domain.com/content/worst-page-of-this-site
www.domain.com/content/worst-page-of-this-site/but/this/one/is/better/

that is not in the iframe of index.php is direct to respectively

www.domain.com/index.php?f=/content/great-content/bla/bla
www.domain.com/index.php?f=/content/worst-page-of-this-site
www.domain.com/index.php?f=/content/worst-page-of-this-site/but/this/one/is/better/

I hope I have made myself more clear! :-)

Last edited by driz : April 24th, 2008 at 02:50 PM. Reason: Added what I want to accomplish, inspired by jeremy's sig :-)

Reply With Quote
  #4  
Old April 29th, 2008, 12:45 AM
driz driz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: top 0; left: 0;
Posts: 67 driz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 19 m
Reputation Power: 5
Is it still unclear what I want?

Reply With Quote
  #5  
Old April 30th, 2008, 07:14 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,124 jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 10 h 58 m 38 sec
Reputation Power: 717
I don't believe the referrer is set when a page is requested through an <iframe>, so I don't think that's a valid test. The src= of the <iframe> most likely causes a completely separate request that is independent of any referrer. You can check this using something like the Live HTTP Headers extension for Firefox.

Do the individual pages (e.g. /content/great-content/foo, /content/worst-page, etc) share a common JavaScript or include()d file of any kind?

Reply With Quote
  #6  
Old April 30th, 2008, 07:17 AM
driz driz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: top 0; left: 0;
Posts: 67 driz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 19 m
Reputation Power: 5
Yes they do, they're all in the same (Wordpress) CMS. Any other ideas on how to solve this?

Reply With Quote
  #7  
Old April 30th, 2008, 08:32 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,124 jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 10 h 58 m 38 sec
Reputation Power: 717
I would be included to take a JavaScript or server side script route. I believe the DOM for any page should include the existence of an <iframe>, so you could use JavaScript to test that. And you could do it server side by adding a query string in the src= for the <iframe> and having each of those pages check for that query string.

You could also do the query string trick with mod_rewrite, but I'm not sure I'd use that in this situation.

Reply With Quote
  #8  
Old May 2nd, 2008, 02:31 AM
driz driz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: top 0; left: 0;
Posts: 67 driz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 19 m
Reputation Power: 5
Quote:
Originally Posted by jharnois
I would be included to take a JavaScript or server side script route. I believe the DOM for any page should include the existence of an <iframe>, so you could use JavaScript to test that. And you could do it server side by adding a query string in the src= for the <iframe> and having each of those pages check for that query string.

You could also do the query string trick with mod_rewrite, but I'm not sure I'd use that in this situation.


You are right, iframe does not set a referer.. I guess than htaccess is not going to work. Thank you for your suggestions to solve this, i'll try the query string option.

Reply With Quote
  #9  
Old May 2nd, 2008, 08:03 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,124 jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 10 h 58 m 38 sec
Reputation Power: 717
Note that you can combine the query string option with mod_rewrite.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Redirect everything under a dir to one page, except if linked from that page..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway