2
votes

I have the following url I want redirect using the .htaccess file in root with Mod Rewrite. I have searched and found good examples for the index file in root, but not in subfolder. This is what I have and what I need. Thank you in advance for your help.

/folder1/index.php /folder1/index.php/ to http://www.example.com/folder1/

/folder2/index.php /folder2/index.php/ to http://www.example.com/folder2/

I was asked for only 2 hyperlinks so I removed part of the link on the examples above. I appreciate the shorter way because I have many folders.

2
I'm not sure you question makes any sense. Do you want to run folder1/index.php but display only folder1/?Codeguy007
This is weird... I'm trying to format with linebreaks and it is impossible. I want this:Camberra CacaitA

2 Answers

0
votes

Try this in your .htaccess file.

RewriteEngine On

Rewrite  ^/folder1/index.php$ /folder1/ [L]
<Directory folder1>
   DirectoryIndex index.php
</Directory>

Of course the index can be what every you want like newindex.php.

0
votes

To redirect /folder/index.php to /folder ,You can use :

RewriteEngine on


RewriteRule ^([^/]+)/index\.php$ /$1/ [NC,L,R]

This will redirect :

  • /anyfolder/index.php

to

  • /anyfolder/