PHP, MySQL, Drupal, .htaccess, Robots.txt, Phponwebsites: How to access pages through one page in site using .htaccess

29 Nov 2013

How to access pages through one page in site using .htaccess

                        You can access all pages from your site through a one page. It can be possible in .htaccess. In this type, you have to specify the other page urls on that one page.

Syntax:
               RewriteRule ^(.*)$ index.php?url=$1 [L]

                    Where, when you try to access any pages in your site, at first your index.php file run. Then it
navigate to where you fixed it to go, it goes to that page. In your index.php should be like this:

                  $url=explode('/',$_GET['url']);
                 if($url[0]=='home.php') {
                   require_once('home.php');
                 }

                        where, you try to access your home.php file, first it comes to index.php and then check whether the home.php page is present or not. It navigates to home.php, if it is present in your site.

You can also hide all your files except home page:

Syntax:
               RewriteRule ^(.*)$ index.php

                  where, whatever you type in your address bar, you should be navigates to your index file.

Related Post:

1 comment:

Note: only a member of this blog may post a comment.