Mobile app version of vmapp.org
Login or Join

Login to follow query

More posts by @Eichhorn148

2 Comments

Sorted by latest first Latest Oldest Best

 

@Gloria169

Most sites with this structure would use mod_rewrite to rewrite all requests to a single file, which would bootstrap a framework or CMS. The CMS or framework would then read and parse the URI and handle internally as designed.

10% popularity Vote Up Vote Down


 

@Kevin317

You can do that with Apache Forcetype.


Typically a web server knows how to
handle requests by the extension any
given file has. For instance, if a
file has a .php extension Apache knows
to parse it for PHP code before
sending it to the browser. Apache's
ForceType directive allows you to
override any default mime types you
have set up. Usually it may be used to
parse an .html page as php or
something similar, but in this case we
will be using it to parse a file with
no extension as php.

So instead of using article.php, as we
did in method 1, rename that file to
just "article" with no extension. You
will be able to access it like this:
www.domain.com/article/999/12/. Utilizing Apache's look back feature
and $PATH_INFO variable as described
in method 1. But as of right now
Apache doesn't yet know to that
"article" needs to be parsed as php.
To achieve that you must add the
following to your .htaccess file.

<Files article> ForceType
application/x-httpd-php
</Files>


This
is known as a container. Instead of
applying directives to all files
Apache allows you to limit them by
filename, location, or directory. You
need create a container as above and
place the directives inside it. In
this case we are using a file
container, we identify "article" as
the file we are concerned with and
then we list the directives we want
applied to this file before closing
off the container.

With the directive inside the
container we are telling Apache to
parse "article" as a php script even
though it has no file extension. This
allows us to get rid of the period in
the URL that causes the problems yet
still use the PATH_INFO method to
manage our site.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme