Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Setting up PHP to allow no .php file extension

Posted on 2011-09-25
Medium Priority
Last Modified: 2012-06-27

I am trying to create a local version of a clients site on my PC (windows 7) running IIS7.

The clients site is running on debian linux, with apache: www.dltphotography.co.uk

When on that site if you navigate to:

It interprets it as recentEvents.php whereas on my machine it doesnt like it. I have access to all the files on the client site and have copied all the website files, thereforeand still get the problem. There is no .htaccess file on the live site that i can see. Therefore it must be to do with the overall setup.

I tries two different setups:
First running the site from IIS and conncting to PHP via CGI, this works fine for most things but no the above.

I then tried running it on an apache install:

Which gives the same problem. Im guessing its something to do with php.ini? or http.conf? i cant see what im supposed to do.

You can review the PHP info by adding demo.php on any of the urls including the client site.

ANy help would be greatly appreciated.

Question by:Dean OBrien
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 400 total points
ID: 36596386
If they have their own server, the rewrite can be set up in the Apache 'httpd.conf' file instead of '.htaccess'.  They are running Apache 2.2.  The rewrite has to be done by Apache because PHP basically gets what Apache gives it.

Assisted Solution

Jelcin earned 400 total points
ID: 36596432

I then tried running it on an apache install:

Your link redirects me to your firewall / router...

If i try the iis some links are broken...


Accepted Solution

maricksville earned 400 total points
ID: 36596558
Hi there.

One thing that you might consider is changing your server from IIS to Apache on your local machine...if this is an option for you. IIS and Apache do work differently and as the remote server is Apache then testing on Apache locally will mean that your testing environment is almost the same as the remote server.

I use EasyPHP which can be found at http://www.easyphp.org/. Its a very simple WAMP installation, and will install Apache, PHP and MySQL for you. You simply create folder and files inside the WWW folder.

The benefit here for using Apache is you can simply create your own htaccess file locally to redirect requests to include the PHP file extension.

When you say you cant see the .htaccess file on the server, what client are you using to access the server? From experience I have logged into a remote server via SmartFTP and there was no htaccess file visible when infact there was one present...it just wasnt visible.

Looking at the demo.php mod_rewrite is loaded.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 400 total points
ID: 36598322
One possible solution would be to use a 404 handler, something like this one that I use on some of my sites.  HTH, ~Ray
<?php // 404handler.php

if (isset($_SERVER["REQUEST_URI"]))

    if (preg_match('#\.php#i', $_SERVER["REQUEST_URI"]))
        header('Location: /');

    $arr = explode('?', $_SERVER["REQUEST_URI"]);
    $arr[0] .= '.php';
    $uri = implode('?', $arr);
    header("Location: $uri");

header('Location: /');

Open in new window

LVL 12

Author Comment

by:Dean OBrien
ID: 36598460
Thanks for all the input.

Ok i have concluded that the IIS version is a dead end due to the configuration differences.

The apache version i am running is one called "EnterpriseDB ApachePHP" which i got prompted to install when setting up Postgres Database (in order to allow pgPHPadmin to work). This has defaulted to port 8081 because IIS is on 80, which appears to conflict with my router port...

I am at work at the moment and intend to try sorting this when i get home.

Would you recommend I:

a) persevere with the Apache version above? (is there much difference between versions?)
b) uninstall above apache and install Apache 2.2?
c) install Debian on a virtual machine so as to guarantee same environment, then install Apache2.2 etc?

I dont want to go to the trouble of the virtual box if its not necessary. The other point is that the live site appears to use "PHP5 + squeeze". Is this squeeze something i should be concerned about? The other thing i notice on the php.info is that it tells it to scan another DIR for .ini files. I cant seem to see where this is defined.

Maricksville - im access using a shell client called WinSCP.

Sorry for long post...


Expert Comment

ID: 36599827
I think that you are going to continue to receive various conflict issues using IIS under Windows. Globally PHP is primarily associated with Apache and Linux, and as such having a similar server environment locally is not a bad idea.

Is the website using Postgresql or MySQL? Are you able to FTP to the server with a client such as FileZilla to check the existence of the htaccess file?

Not to rehash what I said earlier but installing a LAMP/WAMP package is very simple, however these are MySQL packages and I dont know if they support or include Postgresql if that is something you need. Once installed these replicate the server environment very well and will allow you to use htaccess locally.
LVL 12

Author Comment

by:Dean OBrien
ID: 36600053
Hey Marick,
I need to use postgres as that is whats currently installed (never used before...).
I have checked an there is definitely no .htaccess files. FTP isnt setup, but there is a shell comand to view hidden files and it doesnt reveal any.

Im currently in the process of installing Ubuntu server on a virtual machine, which i believe comes with a buncle of applications including apache/php etc.. hopefully this will prove more fruitful...


LVL 43

Assisted Solution

by:David S.
David S. earned 400 total points
ID: 36600197
> When you say you cant see the .htaccess file on the server, what client are you
> using to access the server? From experience I have logged into a remote server
> via SmartFTP and there was no htaccess file visible when infact there was one
> present...it just wasnt visible.

The "." at the beginning of a filename on a Linux system indicates that the file is a hidden file. So to see an ".htaccess" file, you have to make sure that your FTP client is configured to show hidden files.
LVL 12

Author Comment

by:Dean OBrien
ID: 36917274
Sorry for delay, i installed linu / debian on a VM with apache / php and the problems were resolved instantly. Thanks again for input.


Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question