apache mod_rewriting problem o.O

GT9

Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    මචන්ලා අදත් මට ලොකු ප්‍රශ්ණයක් ඇවිල්ලා තියෙන්නේ... අවුල තමයි මචන් apache mod_rewriting ගැන. සරලව මගේ ගැටලුව විස්තර කරනව නම්..

    මට ඕනේ .php extension එක නැති කරල url rewrite කරන්න. ‍මේදේ කරන විදිය ගොඩක් සයිට් වල තිබුනත්.. ඒ විදිය මම හොය ආකාරයම නෙමෙයි.

    උදා:-

    මට ඕන මෙන්න මේ වගේ....

    Code:
    example.com/songs/ -> example.com/songs/
    example.com/songs/samplesong.php -> example.com/songs/samplesong
    example.com/songs/samplesong -> example.com/songs/samplesong/

    ඒ වගේම මචන්ලා.. කවුරු හරි වෙනත් file extension එකකින් ට්‍රයි කරොත් base url එකට redirect වෙන්න ඕන.. මෙන්න ‍මේ වගේ...

    Code:
    example.com/songs/samplesong.htm -> example.com/songs/samplesong
    example.com/songs/samplesong.html -> example.com/songs/samplesong
    example.com/songs/samplesong.rb -> example.com/songs/samplesong
    example.com/songs/samplesong.asp -> example.com/songs/samplesong
    example.com/songs/samplesong.crazy extension -> example.com/songs/samplesong

    මේ ගැන දන්න කෙනෙක් මට මේකට හරියන්න.. apache mod_rewriting code එකක් ලියල දෙන්න... .htaccess එකට දාන්න..

    ලොකු උදව්වක්... :yes: :D
     

    smother

    Well-known member
  • Jan 27, 2009
    19,902
    1,484
    113
    36
    Six Feet Under
    ඔහොම එකක් මතකයි ඉස්සර කාරා . . හිටපන් පොඩ්ඩක් බලන්න
     
    • Like
    Reactions: GT9

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    ඔහොම එකක් මතකයි ඉස්සර කාරා . . හිටපන් පොඩ්ඩක් බලන්න

    ඔහ් මචන්.. පුලුවන් නම් ‍පට්ට උදව්වක්.. මට regex බෑ මචන්.. :sorry: ඒව බැරුව අනිවා මම දන්නවා මට මේක ලියන්න බෑ.. මම මේ දවස්වල regex ට්‍රයි කරනවා.. ඒත් ටිකක් සංක්‍රීරණයි මචන්... :)
     

    D@sun

    Well-known member
  • Oct 25, 2011
    7,652
    662
    113
    Somewhere I Belong ... !
    35.gif
    .. bump!

    ... PHP mathaka neha bn dan:sorry:
     
    • Like
    Reactions: GT9

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    35.gif
    .. bump!

    ... PHP mathaka neha bn dan:sorry:

    මේක මචන් php වලින් බෑ මම හිතන්නේ.. මේකට apache mod_rewriting ගැන දැනගෙන ඉන්න ඕන.. regex ඇතුලුව.. :no:

    අවුලක් නෑ මචන් රිප්ලයි එකට තෑන්ක්ස්..:)
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    Code:
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d # is not example.com/songs/
    RewriteCond %{REQUEST_FILENAME}\.php -f # songs/samplesong.php exists
    RewriteRule ^(.*)$ $1.php

    රිප්ලයි එකට තෑන්ක්ස් මචන්.. බට් මේක හරි යන්නෑ මචන්.. :( rep 3+

    තෑන්ක්ස් :) rep 3+

    thanks
    rep 3+