Redirect to php-file when no extension given
Posted by: magnar@myrtveit.com (---.dhcp.as2116.net)
Date: March 20, 2013 12:54AM

Hi!

I just installed WampServer. When I open for example [localhost] (which is a folder that does not exists), the server delivers the file [localhost] instead. If I create the folder, the folder contents are delivered, as expected. How can I configure the server to deliver a 404-message when the folder does not exist (as I would expect it to do as default), instead of a file that has the same name, except from the extension? I have not enabled mod_rewrite, so there is no .htaccess-file that is causing this to happen.

Best regards,
Magnar

Options: ReplyQuote
Re: Redirect to php-file when no extension given
Posted by: RiggsFolly (---.as13285.net)
Date: March 20, 2013 05:30AM

This makes a change, somebody who wants a 404.


phpMyAdmin however does do some clever stuff.


try using a different address and staying away from phpmyadmin and its folders

http://localhost/doesnotexist

Options: ReplyQuote
Re: Redirect to php-file when no extension given
Posted by: magnar@myrtveit.com (---.dhcp.as2116.net)
Date: March 20, 2013 10:06AM

Hehe. 404s are nice smiling smiley

So I created a new alias [localhost]

In the folder the alias points to, I have a file called newfile.php, and nothing else. When I try to open [localhost], [localhost] is opened. It seems to be working for any file extension, not only php.

When I try to open [localhost] I get the 404 error "The requested URL /test/newfile.php/ was not found on this server."

Any ideas what might cause this? Again, there is no .htaccess-file present in the folder the alias points to.

By the way, how do I prevent the urls from becoming [localhost]-links in these posts?

Options: ReplyQuote
Re: Redirect to php-file when no extension given
Posted by: RiggsFolly (---.as13285.net)
Date: March 20, 2013 03:55PM

Thats because if you dont give it an actual file it looks for one called index.php or index.html


You can change the file it looks for by default but I suggest you work with the default, the rest of the world does.



Edited 1 time(s). Last edit at 03/20/2013 03:56PM by RiggsFolly.

Options: ReplyQuote
Re: Redirect to php-file when no extension given
Posted by: magnar@myrtveit.com (---.dhcp.as2116.net)
Date: March 20, 2013 04:12PM

I don't think that's the reason. If you don't give it a file, it will open index.php or index.html if it exists in the folder, but if you try to open a folder that does not exist, it shouldn't open a file that has the same name as the non-existing folder except for the extension?

The reason this is troublesome is that I have urls looking like /admin/edit/3/. In /admin/ I have a file called edit.php and a .htaccess-file that rewrites /admin/edit/3/ to /admin/edit.php?item=3 But since /admin/edit/ is not a folder that exists, the server rewrites it to /admin/edit.php/3/, which is not something my .htaccess-file handles (and something I don't want it to handle). If I rename the file to edit2.php, the automatic rewrite does not happen, and I can use .htaccess to rewrite /admin/edit/3/ to /admin/edit2.php?item=3, but this is an ugly workaround that I'd prefer not to use.

This behavior can straight out of the box when I installed the "Wampserver (64 bits & Apache 2.4) 2.2E".

Options: ReplyQuote
Re: Redirect to php-file when no extension given
Posted by: RiggsFolly (---.as13285.net)
Date: March 20, 2013 05:00PM

If you are having problems with htaccess isssues, and that what it sounds like, you are already WAY past the help this site is designed for.

Options: ReplyQuote
Re: Redirect to php-file when no extension given
Posted by: magnar@myrtveit.com (---.dhcp.as2116.net)
Date: March 20, 2013 05:16PM

It is not a .htaccess-issue, as I disabled mod_rewrite and deleted the .htaccess-files trying to locate the problem, and the issue is still present sad smiley

Options: ReplyQuote


Sorry, only registered users may post in this forum.