Converting links?

Discussion in 'PHP' started by twistedspikes, May 12, 2008.

  1. #1
    twistedspikes, May 12, 2008 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    research "Mod_Rewrite"

    That is how it is done, and it coded using mostly regex (regular expressions) in, as you know, the .htaccess file.

    I own this book, and highly recommend it.

    www. amazon .com/Definitive-Guide-Apache-mod_rewrite/dp/1590595610/ref=sr_1_1?ie=UTF8&s=books&qid=1210643808&sr=8-1

    remove the space before and after amazon
     
    crath, May 12, 2008 IP
    twistedspikes likes this.
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    I use links in a format that don't require htaccess:

    
    http://site.com/?Page*Variable1*....
    
    Code (markup):
    and then I get the values using PHP:

    
    list($page,$variables1,...) = explode('*',$_SERVER['QUERY_STRING']);
    
    PHP:
    Another option you have is htaccess.

    Peace,
     
    Barti1987, May 12, 2008 IP
    twistedspikes likes this.
  4. twistedspikes

    twistedspikes Notable Member

    Messages:
    5,694
    Likes Received:
    293
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Thanks, i'll look into mod_rewrite and see what I can do :)
     
    twistedspikes, May 12, 2008 IP
    Barti1987 likes this.
  5. nabz245

    nabz245 Well-Known Member

    Messages:
    677
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Use the following in your .htaccess

    
    RewriteEngine On
    RewriteRule ^LINK/(.*)\.html index.php?foo=$1 [L]
    
    Code (markup):
    This will redirect yoursite.com/LINK/variable1.html to index.php?foo=variable1

    Hope that helps!
     
    nabz245, May 12, 2008 IP
    twistedspikes likes this.
  6. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
  7. twistedspikes

    twistedspikes Notable Member

    Messages:
    5,694
    Likes Received:
    293
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Thanks for that. :cool:
     
    twistedspikes, May 12, 2008 IP
  8. kotto

    kotto Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi, there is another issue when converting internal links. Here is the problem: I have a site, say, asite.com, I set up a 301 redirect in a .htaccess file so that everyone who types asite.com get to www .asite.com, and now I need to replace all internal links on my site with URLs containing www. Is there a way to do that using .htaccess?
     
    kotto, May 14, 2008 IP
  9. kotto

    kotto Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I have found a solution. To tell the truth, it was a Joomla issue. If anyone experiences such a trouble, here is a solution to make a Joomla site SEO friendly:
    - On Google webmasters' page, check the first option so that your site will be seen as www .example.com.
    - In Joomla, edit the configuration.php file in /public_html and set "live site" to the URL with "www". Joomla internal links will then display correctly.
    - To enhance Web site security, it is advisable to move your configuration.php out of public_html directory to your root directory and renaming it to "site.conf". Then you should change the contents of the original configuration.php to:
    <?
    require( ‘/home/USERNAME/site.conf’ );
    ?>
    where USERNAME is your account name.
     
    kotto, May 16, 2008 IP
  10. roshanbh

    roshanbh Peon

    Messages:
    52
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    roshanbh, May 16, 2008 IP