Mobile app version of vmapp.org
Login or Join
Reiling115

: Changing mod_rewrite "file exists" checks to not see directories as files I have the following mod_rewrite rules set up: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php

@Reiling115

Posted in: #Apache #ModRewrite #Webserver

I have the following mod_rewrite rules set up:

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


This works fine, allowing me to use "nice" URIs (like mysite.com/about instead of mysite.com/about.php.
However, when I have both a directory and a file with the same name (for example /products and products.php, this breaks as apache just redirects to the directory. Is there a way to fix this?

Thanks,

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling115

1 Comments

Sorted by latest first Latest Oldest Best

 

@Annie201

You can remove RewriteCond %{REQUEST_FILENAME} !-d, but that's going to effectively disable your ability to browse directories or to load a DirectoryIndex page.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme