Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Apache 2.2 is running on port "8080" I want to call my site url (xyz.html is a folder)

as ....

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

share|improve this question

marked as duplicate by MadHatter, Sven, Falcon Momot, Ward, Jenny D Sep 12 '13 at 7:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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. – Daniel Widrick Sep 11 '13 at 18:44
Hi Mint67, Can you please give me the rule. Your help is much appreciated. Thanks – Sreekanth Sagar Sep 11 '13 at 18:55

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.

share|improve this answer
Hi Mint, /www/abc/xyz.html/index.php is the structure. where xyz.html is folder so when I call every thing is good but I want the same result by calling (I want to avoid the "/") thanks – Sreekanth Sagar Sep 11 '13 at 19:08
The Code is Ok but I want the url with out "/" at the end. – Sreekanth Sagar Sep 11 '13 at 20:23

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.

share|improve this answer
This is the error when I call ""; [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 – Sreekanth Sagar Sep 11 '13 at 19:27
I tried bellow htaccess still I am getting the content of folder listed when I call ""; ... DirectorySlash off DirectoryIndex index.php – Sreekanth Sagar Sep 11 '13 at 19:39
Wait sorry, I'll edit the answer to the right form ^^ – Mounir Ahmina Sep 11 '13 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. – Sreekanth Sagar Sep 11 '13 at 19:55
Hmmm, Weird... I'd just format my laptop, I'll install LAMP and test it, If not someone help you before... – Mounir Ahmina Sep 11 '13 at 21:34

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