mask URL
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: mask URL
Apache .htaccess
This snippet will redirect all requests to be handled by index.php. You'll likely end up working extensively on a CMS class module and $_SERVER['REQUEST_URI'].
Think of this as not redirecting access from one file to another, but determining what path was requested and then generating content based on the requested path.
Code: Select all
<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(exception_file.php|exception_folder/) - [L]
RewriteRule !\.(css|cur|exe|gif|gz|html|h3m|ico|jpg|js|mov|mp3|mp4|msi|pdf|pl|png|rar|swf|ttf|txt|wmv|xhtml|xml|xpi|zip)$ index.php
</ifmodule>Think of this as not redirecting access from one file to another, but determining what path was requested and then generating content based on the requested path.
Re: mask URL
Thanks Jab,
So if I get this straight if I copy this code in my .htaccess, then every page will show up as http://www.aaa.ccom, rather than just the only one I want http://www.aaa.com/access.php ? or am I reading it wrong...
So if I get this straight if I copy this code in my .htaccess, then every page will show up as http://www.aaa.ccom, rather than just the only one I want http://www.aaa.com/access.php ? or am I reading it wrong...
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: mask URL
No...
Every file you request (e.g. /, /example1, example2, example3) will be handled by the file specified in the .htaccess. So if you put this in your site's root .htaccess file as then what you can effectively do is program your site to generate any page at any URL. You're not masking, you're creating.
Set this up locally for testing and then request some non-existent URL's. Any content on index.php will be seen on any page you request regardless of it's URL.
That is where $_SERVER['REQUEST_URI'] comes in. You don't have to serve a static copy of index.php...because that file itself can decide what content you use. You'll want to get comfortable with blowing stuff up too while you're at it. No put the TNT down, I mean using PHP's explode function. Explode with '/' and then reference those pieces of pizza as demonstrated on php.net. From that you determine what section, area, page, etc has been requested. From there you determine the HTTP headers (200 found, 403 forbidden, 404 not found, etc) and serve content based on what page was requested in conjunction with how you setup the anchors on the website itself.
It's an engaging method of setting up a site though it's extremely powerful and once you get used to it you'll wonder how the heck you ever did this stuff before.
Every file you request (e.g. /, /example1, example2, example3) will be handled by the file specified in the .htaccess. So if you put this in your site's root .htaccess file as then what you can effectively do is program your site to generate any page at any URL. You're not masking, you're creating.
Set this up locally for testing and then request some non-existent URL's. Any content on index.php will be seen on any page you request regardless of it's URL.
That is where $_SERVER['REQUEST_URI'] comes in. You don't have to serve a static copy of index.php...because that file itself can decide what content you use. You'll want to get comfortable with blowing stuff up too while you're at it. No put the TNT down, I mean using PHP's explode function. Explode with '/' and then reference those pieces of pizza as demonstrated on php.net. From that you determine what section, area, page, etc has been requested. From there you determine the HTTP headers (200 found, 403 forbidden, 404 not found, etc) and serve content based on what page was requested in conjunction with how you setup the anchors on the website itself.
It's an engaging method of setting up a site though it's extremely powerful and once you get used to it you'll wonder how the heck you ever did this stuff before.