|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 :-) |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
Quote:
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 :-) |
|
#4
|
|||
|
|||
|
Is it still unclear what I want?
![]() |
|
#5
|
||||
|
||||
|
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? |
|
#6
|
|||
|
|||
|
Yes they do, they're all in the same (Wordpress) CMS. Any other ideas on how to solve this?
|
|
#7
|
||||
|
||||
|
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. |
|
#8
|
|||
|
|||
|
Quote:
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. |
|
#9
|
||||
|
||||
|
Note that you can combine the query string option with mod_rewrite.
|
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Redirect everything under a dir to one page, except if linked from that page.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|