Mod_rewrite. I still don't undestand

Discussion in 'Apache' started by MilesB, Jun 16, 2007.

  1. #1
    I own www.animeomnitude.com and I am still having trouble trying to get some nice looking SEO friendly URLs but I'm still having trouble.

    They majority of my links look like:
    http://animeomnitude.com/?page=content/main/history
    http://animeomnitude.com/?page=content/main/contact_us
    http://animeomnitude.com/?page=content/movies/narutomovie4/naruto-the-movie-4
    http://animeomnitude.com/?page=media/anime/animeepisodes
    But instead I want them to look like this:
    http://animeomnitude.com/content/main/history
    http://animeomnitude.com/content/main/contact_us
    http://animeomnitude.com/movies/narutomovie4/naruto-the-movie-4
    http://animeomnitude.com/media/anime/animeepisodes

    How can I make it so the rewrite takes away the /index.php?page= so the file path link looks better for all URLs across the board. I would appreciate someone writing it up then explaining how it works for me please
     
    MilesB, Jun 16, 2007 IP
  2. stOx

    stOx Notable Member

    Messages:
    6,426
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    230
    #2
    I don't know how to do it off hand. But those URL's are perfectly SEO friendly. Search engines have no problem spidering URL's with variables in them and they don't rank them any differently.
     
    stOx, Jun 16, 2007 IP
  3. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    what you do is make a file called .htaccess in it you write the following lines
    
    RewriteEngine on
    RewriteRule ^/content/(.*) /index.php?page=content=$1
    
    Code (markup):
    This is just ion the top of my head so you might have to tweak it burt what it does is it says...if you get a request for a file in the folder or subfolder of content you have to look instead for the dynamic content whil still keeping appereances of being static
     
    Edynas, Jun 16, 2007 IP
  4. MilesB

    MilesB Well-Known Member

    Messages:
    1,813
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    180
    #4
    So I just upload the .htaccess file into my public_html directory. No link editing needed?


    Edit: My links haven't changed at all
     
    MilesB, Jun 16, 2007 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    You have to change the links. It doesn't magically edit the php file!!!
     
    Nintendo, Jun 16, 2007 IP
  6. MilesB

    MilesB Well-Known Member

    Messages:
    1,813
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    180
    #6
    MilesB, Jun 16, 2007 IP
  7. Toopac

    Toopac Peon

    Messages:
    4,451
    Likes Received:
    166
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah now you have to edit the php file just like Nintendo said, making the URL the same as the new SEO friendly one you put in your .htaccess file.
     
    Toopac, Jun 17, 2007 IP
  8. MilesB

    MilesB Well-Known Member

    Messages:
    1,813
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    180
    #8
    Yea I already edited my index.ph seeing as that is the only file I need to change.

    I changed <a href="?page=content/interviews/steveprince/steveprince">Steve Prince</a>
    to
    <a href="content/interviews/steveprince/steveprince">Steve Prince</a> <br>

    But when I click on it it produces a 404
     
    MilesB, Jun 17, 2007 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #9
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ index.php?page=$1 [L]
     
    Nintendo, Jun 18, 2007 IP