+ Reply to Thread
Results 1 to 5 of 5

Thread: help me with url rewriting

  1. #1
    bioshock's Avatar
    bioshock is offline x10Hosting Member bioshock is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    27

    help me with url rewriting

    i need to redirect images named with punk.png
    to document_root/punk.png

    for better explanation

    a url of the image is http://www.example.com/subdir/subdir/punk.png it should redirect to
    http://www.example.com/punk.png


    i have done something but didn't work .
    Code:
    RewriteEngine on
    
    RewriteRule ^dl.png http://example.com/dl.png

  2. #2
    Zubair's Avatar
    Zubair is offline x10 Super Spammer Zubair has a reputation beyond reputeZubair has a reputation beyond reputeZubair has a reputation beyond repute
    Join Date
    Jul 2009
    Location
    Pakistan
    Posts
    8,747

    Re: help me with url rewriting

    Add this line at TOP of .htaccess file
    RewriteBase /”
    and see if it works
    Zubair Barkat | Level 2 Tech
    █ 888-X10-9668 - zubair[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: help me with url rewriting

    Example URLs should be live. Rather than making up names, give real ones that can be tested.

    Also, the location of the .htaccess file with the directives matters. The example you give should be in "[DOCUMENT ROOT]/subdir/subdir/.htaccess". If you want every URL ending with "punk.png" to be redirected, add the following in [DOCUMENT ROOT]/.htaccess:
    Code:
    RewriteRule punk.png$ /punk.png
    This also uses an internal redirect. The rewrite isn't visible to the site visitor (which may or may not be desirable) and is more efficient. An external redirect sends a message to the browser that the resource is at a different URL, which then has to issue a second request.

    You'll still need the RewriteBase directive under the new virtual host configuration (see how useful it is to read the service alerts?).
    Last edited by misson; 06-11-2010 at 06:06 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  4. #4
    bioshock's Avatar
    bioshock is offline x10Hosting Member bioshock is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    27

    Re: help me with url rewriting

    yes i was looking for internal redirect thanks misson would you please explain how it works i mean the syntax

    what the $ sign for

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: help me with url rewriting

    Quote Originally Posted by bioshock View Post
    would you please explain how it works i mean the syntax
    What part of the syntax, exactly? You get an external rewrite whenever you include the scheme and host name in the substitution URL, or you use the redirect flag (R). Use neither the flag nor the scheme and you have an internal redirect. Read the rewrite engine documentation for more.

    Quote Originally Posted by bioshock View Post
    what the $ sign for
    The pattern in a rewrite rule is a regular expression. The "$" atom matches the end of a string. Read up on the most basic features of regular expressions to start, then pick a RE tutorial for the rest.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. URL rewriting not working anymore
    By abcroste in forum Free Hosting
    Replies: 9
    Last Post: 06-11-2010, 01:16 AM
  2. Help rewriting /index.php to /index
    By leafypiggy in forum Programming Help
    Replies: 7
    Last Post: 03-26-2010, 10:59 AM
  3. htaccess URL rewriting
    By jayar in forum Programming Help
    Replies: 1
    Last Post: 01-14-2010, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers