Forum Moderators: open

Message Too Old, No Replies

force file in DIV

DIV AJAX dynamic content

         

markla

11:35 am on Dec 25, 2008 (gmt 0)

10+ Year Member



HI I 've a problem with understanding redirecting files.

when someone visits my website they will access the index.php

www.mywebsite.com/index.php


<?php
echo"
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
<html>
<head>
<title>Ajax dynamic content</title>
<script type='text/javascript' src='js/ajax.js'></script>
<script type='text/javascript' src='js/ajax-dynamic-content.js'></script>
</head>
<body>
<div id='mainContainer'>
<p class='header'>
The content of the three boxes below are loaded by Ajax(Asyncron Javascript And XML) from external files.</p>
<div class='news' id='news1'><!-- Empty div for dynamic content -->Loading news. please wait...</div>
<div class='news' id='news2'><!-- Empty div for dynamic content -->Loading news. please wait...</div>
<div class='news' id='news3'><!-- Empty div for dynamic content -->Loading news. please wait...</div>
</div>
<script type='text/javascript'>
ajax_loadContent('news1','external/externalfile1.html');
ajax_loadContent('news2','external/externalfile2.html');
ajax_loadContent('news3','external/externalfile3.php');
</script>
</body>
</html>";
?>

But there is a change the someone enters the website via www.mywebsite.com/external/ He could start one of the files that are located in the external directory, like externalfile3.php.

I KNOW I can use .HTTACCES or CHMOD to prevent people to open the directory external, thats not my problem.

I realy would realy like to know how I can force a file like externalfile3.php in to its index.php file when someone try to open it outsite the index.php

I hope you could help me

g1smd

3:06 pm on Dec 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Assuming you use an Apache webserver, you will need a
RewriteRule
with
[R=301,L]
. The rule will test the URL that was asked for (bare folder name, and folder with filename) and then issue a redirect to the URL you want the user to access. The target URL will contain the full hostname too.

There's hundreds of examples throughout the Apache forum here.

markla

7:23 pm on Dec 25, 2008 (gmt 0)

10+ Year Member



Oke i've seen lots of Rewrite thing......that I don't understand (yet). I was thrying to use a define in the index and a defind in the ' child' file and use that to check whether the file was opened through or outsite the the index file an than reditect.