Results 1 to 3 of 3
  1. Donator Straight Female
    IGN: icephoenix21
    Server: Scania
    Level: 212
    Job: Bishop
    Guild: DremithCross
    Alliance: Evolution
    Farm: IcePhoenix

    Default Getting rid of file extensions such as .html and .php

    Hello, I'm in need of some help for a course assignment. I've done all of the major work for this web design assignment, except for the following part,

    "Build your site so the URLs for each page are in this easy-to-type format, and users don't even know they're accessing PHP files"

    I realize that if I have each page in it's own directory, and labeled as index.php, then the file can be accessed without the php extension (example: "" ). However, the problem with that is when you type it in, it simply redirects you to "".

    I'm fairly certain that the instructor wants us to have it so that the web page displays no .php or .html extension.
    I've tried to google search around a bit, and it seems that there is a php code that deals with having an htaccess file, as well as this string of coding:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php

    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^([^.]+)$ $1.php [NC,L]

    Is there any simpler way to do this? The class really hasn't gotten into much php at all, so this seems a bit advanced for the classwork at the moment.

  2. Default Re: Getting rid of file extensions such as .html and .php

    There is no other way than modrewrite that I'm aware of, so yes you have to use a htaccess file.

    Some tips for beginners:


  3. Default Re: Getting rid of file extensions such as .html and .php

    .htaccess files have nothing to do with php, they're control modules for apache.

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    Should really be all you need for most cases. It doesn't have to be in an .htaccess file either, you can put it directly in your httpd.conf at any level if you want it to effect all sites, or site wide to a specific site regardless of folder depth. htaccess files are overrides to the default conf.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts