Sebastjan
Sebastjan

Reputation: 1147

htaccess back to index

I'm currenty working on a project, which has the following linking method If the link is
www.foo.com/sub/foo.php?o=1000 it opens MyContacts

www.foo.com/sub/foo.php?o=608 it opens XYZ

... The whole site is built on this, and only the number changes.

But you can access those files directly: www.foo.com/sub/file1000.php

So my question now is, is it possible to redirect to

www.foo.com/sub/foo.php?o=1 - (index page) if the link is anything other than www.foo.com/sub/foo.php

I guess this can or could be done within .htaccess, but I don't have any knowlege in .htaccess programming.

Ty, Sebastjan

Upvotes: 0

Views: 47

Answers (1)

David Houde
David Houde

Reputation: 4778

This can be done with .htaccess, but generally I would recommend removing any content you do not want directly accessed from the documentroot. PHP can still access files that sit below your public directory.

If you use .htaccess, be sure to set specific rules, otherwise all image and css requests will be redirected back to the index

Otherwise, you can also put a line into your foo.php:

define('ISINCLUDED', 'YES');

and in each foo10000.php:

if(!defined('ISINCLUDED')) return;

Upvotes: 1

Related Questions