-1

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

Daniel Widrick
  • 3,418
  • 2
  • 12
  • 26
Sreekanth Sagar
  • 39
  • 1
  • 14
  • 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. – 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

2 Answers2

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.

Daniel Widrick
  • 3,418
  • 2
  • 12
  • 26
  • Hi Mint, /www/abc/xyz.html/index.php is the structure. where xyz.html is folder so when I call http://www.mysite.in:8080/abc/xyz.html/ every thing is good but I want the same result by calling http://www.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
-1

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.

  • This is the error when I call "http://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 "http://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
  • Ohhh, How dump I am, I didn't notice... I'll update my answer ^^ – Mounir Ahmina Sep 11 '13 at 21:50
  • Hi Mounir,Internal Server Error again [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 12 '13 at 15:44