how can i remove space from url ? and replace with -

Discussion in 'PHP' started by matrex722, Nov 8, 2010.

  1. #1
    hi

    i want to remove a space from the name in my url

    in the php file

     
    if($kedi==1) {
            $kekeywordslinks .="<tr>"; }
            if($htmllink==on) {
            $link="tag-".$ewords[$i]."-0.html";
            } else {
            $link="tags.php?a=$ewords[$i]";
            }
    
    PHP:
    0 = page id

    for the first page if the tag is only one word its ok

    if the tag 2 words the url contain 20% between the words

    and if i clicke on the page 2 the page and url becom wrong

    can you please help me in this

    and this is .htaccess code

    RewriteRule ^tag-(.*)-([0-9]+)\.html$ tags.php?a=$1&lng=$2&page=$3
    RewriteRule ^tag-(.*)-page([0-9]+)\.html$ tags.php?a=$1&page=$2
     
    matrex722, Nov 8, 2010 IP
  2. themullet

    themullet Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #2
    str_replace(" ","-", $subject)
     
    themullet, Nov 8, 2010 IP
  3. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    when i use this for $ewords[$i]

    work with url

    i mean it replace space with -

    but when i open the url

    the page is wrong

    i think it require doing somthing in .htaccess file

    but i dont know what it is
     
    matrex722, Nov 8, 2010 IP
  4. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #4
    can any one please help me
     
    matrex722, Nov 9, 2010 IP
  5. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #5
    Try str_replace(" ","+", $ewords[$i]); it+will+come+out+like+this.html which is fine, fingers crossed:)
     
    MyVodaFone, Nov 9, 2010 IP
  6. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #6
    with this i must change in .htaccess or not need to change ?
     
    matrex722, Nov 9, 2010 IP
  7. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #7
    The + sign is really just a form of urlencoding, it should not take any effect on a url, however since you posted the above question, I am guessing you tried it already, so now I'm thinking what your asking has nothing to do with your problem.

    Please post an example of a URL your trying to apply ewords to.
     
    MyVodaFone, Nov 9, 2010 IP
  8. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #8
    Last edited: Nov 10, 2010
    matrex722, Nov 10, 2010 IP
  9. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #9
    helloo

    can any one help me
     
    matrex722, Nov 15, 2010 IP
  10. dansari

    dansari Well-Known Member

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    108
    #10
    Please post the code you are using to obtain the value of eword.
     
    dansari, Nov 16, 2010 IP
  11. peonboy

    peonboy Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    why dont you replace space with underscore?
    str_replace(" ","_", $subject)
     
    peonboy, Nov 17, 2010 IP
  12. samyak

    samyak Active Member

    Messages:
    280
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    90
    #12
    Show us what values $ewords[$i] holds and I will be able to help you.
     
    samyak, Nov 18, 2010 IP
  13. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #13
    it show words in the url

    as i sent above

    if it is one word the url work fine like :

    http://www.7elm3aber.com/ptag-mobile-0.html

    $ewords[$i] = mobile

    see the pages urls

    its work without any problem

    but if it is 2 words or more it doest work

    only first page like

    http://www.7elm3aber.com/tetag-nokia+c5-0.html

    $ewords[$i] = nokia+c5

    replacing space with +

    try to go to page 2

    you will find url become :

    http://www.7elm3aber.com/tetag-nokia

    thats wrong

    it must be

    http://www.7elm3aber.com/tetag-nokia+c5-page2.html

    so the wrong is from .htaccess file

    somthing is missing
     
    matrex722, Nov 20, 2010 IP
  14. helloguys12345678

    helloguys12345678 Greenhorn

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    20
    #14
    or you can try

    str_replace(" ", "%20", $url);
     
    helloguys12345678, Nov 20, 2010 IP
  15. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #15
    i did that str_replace(" ", "%20", $url);

    replacing it with %20
    and -
    and +
    and _
    all the same problem in page 2
     
    matrex722, Nov 21, 2010 IP
  16. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #16
    hello

    can anyone help ?
     
    matrex722, Nov 29, 2010 IP
  17. matrex722

    matrex722 Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #17
    can you plz help
     
    matrex722, Jan 27, 2011 IP