Need Redirection help with htaccess

Discussion in 'Apache' started by ish1301, Nov 7, 2006.

Thread Status:
Not open for further replies.
  1. #1
    Hello Experts

    I wanna implement URL rewrite mode as such

    URL = http://dir.netpowersoft.com/Arts/Animation/Technical_Process/

    (Note /Arts/Animation/Technical_Process/ these are not directories)

    Re-Written as = http://dir.netpowersoft.com/index.php?arg=Arts/Animation/Technical_Process/

    Currently I am using .htaccess as:-
    
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule /(.*) /index.php?arg=$1
    
    Code (markup):
    *** But with this code images are not loading on. I am stuck now !!!

    Any help be appreciated ...

    Thanks for your time
     
    ish1301, Nov 7, 2006 IP
  2. vishwaa

    vishwaa Well-Known Member

    Messages:
    271
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    138
    #2
    Try avoiding relative path to images.

    You may use like <img src="/image_folder/smile.gif" alt="" width="xx" height="xx" />
     
    vishwaa, Nov 7, 2006 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Have the image code as if the mod_rewrite URLs are the real URLs. The browser has no idea you're using mod_rewrite!!!!
     
    Nintendo, Nov 7, 2006 IP
  4. ish1301

    ish1301 Banned

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ish1301, Nov 8, 2006 IP
  5. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    That's not correct.

    If you use "image_folder/smile.gif",
    - at site index it will be http://dir.netpowersoft.com/image_folder/smile.gif (OK here)
    - at inner pages like http://dir.netpowersoft.com/Arts/ it will be (http://dir.netpowersoft.com/Arts/image_folder/smile.gif) (Not OK),
    but if you use "/image_folder/smile.gif",
    - at site index it will be http://dir.netpowersoft.com/image_folder/smile.gif (OK here)
    - at inner pages like http://dir.netpowersoft.com/Arts/ it will be (http://dir.netpowersoft.com/image_folder/smile.gif) (OK too).

    Jean-Luc
     
    Jean-Luc, Nov 8, 2006 IP
    vishwaa likes this.
  6. ish1301

    ish1301 Banned

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    @Jean-Luc

    that's alright

    Anyways my problem is images not loading (no matter there path is correct or not ) !!! even if i use ("/images/logo.gif")

    Is it because of htaccess ? and how can i fix it ?

    thanks for your time !!!
     
    ish1301, Nov 8, 2006 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #7
    Is

    http://dir.netpowersoft.com/images/logo.gif

    the URL of the image? If so, mod_rewrite is making it look like a directory!!!

    Top > images > logo.gif

    Try

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ index.php?arg=$1 [L]

    and if that doesn't work, try

    RewriteRule ^dir/([^.]+)$ index.php?arg=$1 [L]

    with all the URLs having dir/ in them.
     
    Nintendo, Nov 8, 2006 IP
  8. ish1301

    ish1301 Banned

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    @Nintendo

    I worked :) .... that's the reason i really like you guys !

    thanks buddy !!!
     
    ish1301, Nov 8, 2006 IP
  9. ish1301

    ish1301 Banned

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    everthing goes fine until i have .... new problem :confused:

    .htaccess file code :-
    
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ index.php?arg=$1 [L]
    
    Code (markup):
    this code also redirect http://dir.netpowersoft.com/admin/ to index.php, how can i stop redirection?
     
    ish1301, Nov 8, 2006 IP
  10. WhiteHatHacker

    WhiteHatHacker Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    BEFORE the above RewriteRule, add
    RewriteRule ^admin/ - [L]
    Code (markup):
    and
    RewriteRule ^admin$ /admin/ [R=301,L]
    Code (markup):
    I'm not sure if you need a slash between "^" and "admin" in both.

    Anyway, the first stops redirection of anything under the admin foler, and the latter one makes sure that if "admin" does not have a trailing slash (as in "www.aaa.com/admin" instead of "www.aaa.com/admin/"), that the slash is added.

    I think that's right. Try messing about a bit if they don't.
     
    WhiteHatHacker, Nov 8, 2006 IP
  11. ish1301

    ish1301 Banned

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    @WhiteHatHacker

    Complete and best answers ..... Problem Solved

    ... Thanks Again !!!
     
    ish1301, Nov 8, 2006 IP
  12. WhiteHatHacker

    WhiteHatHacker Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    You're welcome :)

    Thanks.
     
    WhiteHatHacker, Nov 8, 2006 IP
Thread Status:
Not open for further replies.