/    Sign up×
Community /Pin to ProfileBookmark

Apache Assumes file Extensions

I’ve searched far and wide, high and low, in and out, above and beneath, and through and around for the answer to this question, but have not found ONE SINGLE THING.

I am running WAMP (Apache, MySQL, and PHP) on my computer, and Apache is working fine, except for when I wanted to use mod_rewrite. I created a file in my directory called archive.php, and then another one called entry.php. If the user enters a URL such as /archive/05056/ it will take them to entry.php?e=05056, and if they enter /archive/, it will take them to archive.php.

Now, this would be working fine, except Apache seems to want to thrown on file extensions when none are given (I type in /index and it takes me to index.php, even though I didn’t tell mod_rewrite to do it). This causes it to go to archive.php no matter what URL is entered ? Any ideas how to stop it from doing this?

Thanks in advance,
Dan

to post a comment
Full-stack Developer

10 Comments(s)

Copy linkTweet thisAlerts:
@ray326Oct 30.2004 — A couple of WAGs:

Remove all the file names from the DirectoryIndex list.

Allow indexes everywhere.
Copy linkTweet thisAlerts:
@Daniel_TauthorOct 30.2004 — [i]Originally posted by ray326 [/i]

[B]A couple of WAGs:

Remove all the file names from the DirectoryIndex list.

Allow indexes everywhere. [/B]
[/QUOTE]


  • 1. Why would that help? Anyway, I don't want to do that, because I want it to display the homepage when I just type in localhost/, rather than typing localhost/index.php. This is a testing server, and therefor I would like to be able to use relative links to the homepage with the HREF of "/", like I would on my webspace.


  • 2. Listings already are allowed in each directory, so long as there isn't an INDEX page.


  • ?
    Copy linkTweet thisAlerts:
    @ray326Oct 30.2004 — Ok, so your rewrite rules would be?
    Copy linkTweet thisAlerts:
    @Daniel_TauthorOct 31.2004 — RewriteRule ^archive/([0-9])+/? /entry.php?e=$1
    RewriteRule ^archive/?$ /archive.php

    Those are the only ones...
    Copy linkTweet thisAlerts:
    @ray326Oct 31.2004 — Ok so it's not rewrite. Maybe "index" is special. If you use /foobar does it give you a 404 foobar.php not found?
    Copy linkTweet thisAlerts:
    @Daniel_TauthorOct 31.2004 — [i]Originally posted by ray326 [/i]

    [B]Ok so it's not rewrite. Maybe "index" is special. If you use /foobar does it give you a 404 foobar.php not found? [/B][/QUOTE]
    The requested URL /foobar was not found on this server.[/quote]
    But if I put a foobar.php file in the root directory, then go to localhost/foobar, it will take me to foobar.php.

    [b]EDIT[/b]

    It seems to only be doing this in the directory with the .htaccess file in it (a subdirectory. I am storing all this stuff in a subdirectory from the doc_root, btw ?)
    Copy linkTweet thisAlerts:
    @ray326Nov 01.2004 — Well I'm about out of ideas. Maybe that's a "feature" of mod_php if you're running PHP that way instead of through the CGI.
    Copy linkTweet thisAlerts:
    @Stephen_PhilbinNov 01.2004 — I've only ever used a hand-full of servers, but they all seem to have preferred index.php over index.html when only the directory name is specified.
    Copy linkTweet thisAlerts:
    @NevermoreNov 01.2004 — This sounds like Apache's content negotiation - it shouldn't normally be a problem, and is recommended for web sites because it allows you to change the underlying technology without changing the filenames and all your links. I'm using it on deiform.co.uk - go to http://deiform.co.uk/index, for example, and you might as well have gone to index.php. It's more secure and keeps the links fixed.

    However, I can understand it being a problem on your testing server. To turn it off, try putting
    <i>
    </i>Options All

    into your .htaccess file, assuming allowOverride is set to on. Alternatively, you can find the option for it in the server config files, or just change your file names.
    Copy linkTweet thisAlerts:
    @Daniel_TauthorNov 01.2004 — Thanks Nevermore! That worked perfectly! And thanks for your help aswell, ray ?
    ×

    Success!

    Help @Daniel_T spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.25,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...