Forum Moderators: phranque
Hope someone can help with this I have the following .htaccess in subfolder directory/
RewriteEngine off
RewriteEngine On
redirectMatch permanent ^/directory/?$ http://www.example.com/directory/index.php
requests to http://www.example.com/directory/ are redirected to http://www.example.com/directory/index.php
This is to prevent duplicate content. I must redirect to index.php as the script installed in the directory needs this to function.
However if I type http://www.example.com/directory/index (no.php) this links to the page, all other endings show "404 Not Found"
only ending /index produces this effect.
Why only /index and how can I fix this?
Thanks
[edited by: jdMorgan at 4:09 pm (utc) on Aug. 28, 2008]
[edit reason] Please use "example.com" [/edit]
Also, RedirectMatch is part of mod_alieas, not mod_rewrite, so the RewriteEngine on is not needed. And certainly, there's no reason to precede it with RewriteEngine off in any case.
You're going to need to back up and find out the settings of DirectoryIndex, MultiViews, and (if on Apache 2.x) AcceptPathInfo. All of these can lead to unexpected URL-to-filename mappings, in addition to obvious URL-to-filename translators such as mod_alias and mod_rewrite.
Jim
So now the question becomes, "Why do you want to -or think you need to- redirect to index.php?
A more common setup would be to define index.php as your DirectoryIndex, link only to "/", and then redirect requests for index.php back to "/". I strongly suggest that you consider that approach, as it is 'standard' and leaves you free to change your scripting technology with a single change to your configuration file in the future.
Jim