1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Mod Rewrite for my apache

Discussion in 'Apache' started by malchiang, Jul 18, 2007.

  1. #1
    Hi to all the experts here, I just would like to accomplish the following for my site


    www.domainname.com/*** to point to www.domainname.com/***.php


    Pls help urgently, much appreciated.


    Cheers
    malchiang
     
    malchiang, Jul 18, 2007 IP
  2. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    pls help anybody
     
    malchiang, Jul 19, 2007 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ $1.php [L]
     
    Nintendo, Jul 20, 2007 IP
  4. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thx nintendo I will try it, I dun seem to have the .htaccess file in my apache2, where shd I create this file? much appreciated.
     
    malchiang, Jul 23, 2007 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    domain.com/.htaccess
     
    Nintendo, Jul 23, 2007 IP
  6. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #6
    Nintendo, why did you add +Indexes ? It is not necessary to do this redirect and it is off by default for a reason...
     
    krt, Jul 23, 2007 IP
  7. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi, So I just use the following?

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ $1.php [L]
     
    malchiang, Jul 23, 2007 IP
  8. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    just tried both lines in my .htaccess file I created in my web root dir, but it does not work cos when I key in domainname/*** it just gives me a 404 error, pls advise guys. Much appreciated.
     
    malchiang, Jul 23, 2007 IP
  9. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Can someone here help?
     
    malchiang, Jul 24, 2007 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #10
    Try it with the first line being

    Options +FollowSymLinks +Indexes
     
    Nintendo, Jul 25, 2007 IP
  11. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    hi nintendo I tried the following but it still gives me 404, any idea what I am doing wrongly? Thanks.

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/$ $1.php [L]
    RewriteRule ^([^.]+)$ $1.php [L]


    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ $1.php [L]


    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ $1.php [L]
     
    malchiang, Jul 26, 2007 IP
  12. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #12
    Indexes option is irrelevant for this.

    Now your 404 is probably due to a misunderstanding of how the rewrite works. Can you tell me what URL you tried to request when the 404 came up?

    e.g. if you tried example.com/test, are you sure there is a test.php on your server web root?
     
    krt, Jul 26, 2007 IP
  13. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Hi krt,
    Yes I go to e.g. example.com/phpinfo.php it comes out but when I type in example/phpinfo I get the 404 error. Wat am I doing wrong?
     
    malchiang, Jul 26, 2007 IP
  14. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #14
    Try a little test.

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^wacko\.html$ index.php [L]

    domain.com/wacko.html should then show the index.php file.
     
    Nintendo, Jul 27, 2007 IP
  15. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #15
    I think the htaccess file is not being processed, or is named incorrectly / not in your web root.

    Nintendo's test should be fine, you may also want to do this, I just use a .htaccess with nothing but an "x":
    x
    Code (markup):
    And there should be a 500 server error when you access any file in your site.
     
    krt, Jul 27, 2007 IP
  16. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #16
    And if that test doesn't work, try just

    Options +FollowSymLinks

    for the first line, or with out any of it. Different servers might want different code or nothing there. My server for example needs both codes there. It would spit out a 404 error if I didn't have them, hince I use both codes.
     
    Nintendo, Jul 27, 2007 IP
  17. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    sorri folks cos I am an idiot in apache, how do I make sure .htaccess file is correctly activated in apache as i had put it in /htdocs/ which is my root specified in http.conf, can you guys guide me the steps? Thanks.
     
    malchiang, Jul 28, 2007 IP
  18. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #18
    Um, you got it in da wrong spot!!!!!!!!!

     
    Nintendo, Jul 28, 2007 IP
  19. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #19
    No, it is the right spot. domain.com/.htaccess resolves to /path/to/web/root/.htaccess or htdocs/.htaccess in this case.

    malchiang, did you try what I suggested (in post #15)? What was the result?

    This will take a while to solve so if you want, try contacting your host, perhaps .htaccess files are not allowed. Also, if you are willing to give me FTP access, I can try find out the problem that way.
     
    krt, Jul 28, 2007 IP
  20. malchiang

    malchiang Peon

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Hi gentlemen, i tried putting x in the .htaccess file but I am still able to access example.com/phpinfo.php, I am currently using a dedicated server running apache 2.24 pls help.
     
    malchiang, Jul 29, 2007 IP