Rewrite URL .htaccess file

Discussion in 'Site & Server Administration' started by dark0circles, Nov 13, 2007.

  1. #1
    Hi.. I need to do this..

    From
    http://www.yourdomain.com/index.php?expansion={expansion}&seed={seed}&final={final}
    to
    http://www.yourdomain.com/{expansion}/{seed}/{final}

    In .htaccess file
    RewriteEngine on
    RewriteRule ^([^/\.]+)/([^/\.]+)/[^/\.]+)/?$ index.php?expansion=$1&seed=$2&final=$3 [L]
    Code (markup):
    It doesn't rewrite the URL..

    This is the another code that I get from other forum.
    http://forum.modrewrite.com/viewtopic.php?p=15084&sid=427975dd881fdcdae0c410de104c2bf4

    Options +FollowSymLinks

    RewriteEngine On
    
    
    RewriteRule ^seed/([^/]+)/expansion/final/?$ ./index.php?seed=$1&expansion=$1&final=$1 [QSA,L]
    
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{QUERY_STRING} ^(.*&)?seed=([^&]+)(&.*)?$ [NC]
    RewriteRule ^index\.php$ /ppc/seed/%2/expansion/final/? [R=301,L]
    Code (markup):

    It doesn't rewrite the URL as well. Anyone can help? Thank you.:)
     
    dark0circles, Nov 13, 2007 IP
  2. dark0circles

    dark0circles Peon

    Messages:
    660
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    dark0circles, Nov 13, 2007 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/([^.]+)/([^.]+)$ index.php?expansion=$1&seed=$2&final=$3 [L]

    Links have to be edited to link to the new URLs.
     
    Nintendo, Nov 14, 2007 IP
  4. dark0circles

    dark0circles Peon

    Messages:
    660
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi Nintendo, thanks for your help. Can you explain more about what do you mean by Links have to be edited to link to the new URLs?

    I've try the code but it doesn't change the URL.
     
    dark0circles, Nov 14, 2007 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    If you link to the dynamic URLs, you won't get mod_rewrite URLs. mod_rewrite doesn't change links, you have to edit the script yourself. It's like thinking you can change files from .asp to .php and the URLs will magically change with out editing the code that spits out the links.
     
    Nintendo, Nov 15, 2007 IP