php - Force included pages to be included (i.e. not opened by themselves) -
i in process of creating own cms system because of tired of wordpress (and hack attempts come it).
my question this: there way force pages in includes directory opened included pages? looking @ doing allowing search engines crawl public_html/blog_files , /public_html/pages folders, if google displays them in searches, want open included page inside of pre-determined page.
typically, website call single_post.php page blog_abc123.php page included. if opens blog_abc123.php, want include inside of single_post.php page , display single_post.php page blog_abc123.php in it.
i hope explained well, , can understand idea.
thanks in advance help.
why includes publicly accessible in first place? need fix that.
in meantime, can use get_included_files() returns array containing files have been included in script far. counting contents of array, can determine if current file being included or not (because if not, file). can redirect correct parent page:
<?php if (count(get_included_files()) == 1) { header('http/1.1 301 moved permanently'); header('location: /the-correct-url'); exit; }
google see 301 , index site correctly.
with said, it's odd want these includes crawled in first place. better use sitemap correct urls.
Comments
Post a Comment