My Apache 2.2 is running on port "8080" I want to call my site url http://www.example.in:8080/abc/xyz.html/index.php (xyz.html is a folder)

as ....


Can any one help me with the .htaccess for this..

  • 2
    you should not do this.... just use mod_rewrite to rewrite xyz.html to index.php. Trying to name folders like that and exploit apache's index file features is a good way to cause all kinds of unexpected (SEE: unpredictable) behavior. Sep 11, 2013 at 18:44
  • Hi Mint67, Can you please give me the rule. Your help is much appreciated. Thanks Sep 11, 2013 at 18:55

2 Answers 2


The rule will depend on exactly how you want it to behave.

RewriteEngine On
RewriteRule ^(.*).html $1.php 

might get you close. Then create the file /wwwroot/abc/xyz.php or what ever instead of /wwwroot/abc/xyz.html/index.php

Ultimately you're searching (googling) for a way to rewrite html files to php that fits your use case.


Here's you purpose:

RewriteEngine On
RewriteRule ^(.*).html $1.html/index.php 

But I guess you can do alternatives way that will not cost you making all those directories... Or maybe you're right that's the right and the only way to do it (For your purpose).


You can't do this action because the browser will keep redirecting... On Apache by default it's redirect /dir to /dir/ if it is available, But I guess you can disable that from the config file (It is possible on nGinx at least) But that will force you and your visitors to put the "/" after every URL in case of directory. Our .htaccess will redirect it as a rewrite again and will never get the right path... So instead of that you can use a .htm page by:

RewriteEngine On
RewriteRule ^(.*).htm $1.html/index.php

Or (mostly) any other form you choose will work fine.

  • This is the error when I call "mysite.in:8080/abc/xyz.html" [error] [client] File does not exist: /var/www/abc/www/xyz.html/index I kept the bellow content in .htaccess and placed the file in side the xyz.html folder RewriteEngine On RewriteRule ^(.*).html $1/index.php Sep 11, 2013 at 19:27
  • I tried bellow htaccess still I am getting the content of folder listed when I call "mysite.in:8080/abc/xyz.html" ... DirectorySlash off DirectoryIndex index.php Sep 11, 2013 at 19:39
  • Wait sorry, I'll edit the answer to the right form ^^ Sep 11, 2013 at 19:51
  • Hi Mounir,Internal Server Error [error] [client] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. Sep 11, 2013 at 19:55
  • Hmmm, Weird... I'd just format my laptop, I'll install LAMP and test it, If not someone help you before... Sep 11, 2013 at 21:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.