Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ....

http://www.example.in:8080/abc/xyz.html

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

share|improve this question
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. –  lVlint67 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
add comment

marked as duplicate by MadHatter, SvW, 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.

2 Answers

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 mysite.in:8080/abc/xyz.html every thing is good but I want the same result by calling mysite.in:8080/abc/xyz.html (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
add comment

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).

Update

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 "mysite.in:8080/abc/xyz.html"; [error] [client 115.241.220.228] 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 "mysite.in:8080/abc/xyz.html"; ... 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 115.241.220.228] 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
show 2 more comments

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