Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    11
    Thanks
    1
    Thanked 1 Time in 1 Post

    Banging my head trying to create my own permalinks with htaccess

    Hey guys,

    I've got no idea what I am doing here, I've been trying to read tutorials on how to use the RewriteRule to create my own permalinks. I can't make much sense of them, If anyone knows any good tutorials please let me know.

    I want to change my url, so this happens

    example :

    http://www.mysite.com/productpage.ph...me=SUPER+AMINO

    will turn into www.mysite.com/Dymatize/SUPER+AMINO/

    I don't want the productidpage variable to be factored into the url rewrite, but the $_GET['productidpage'] needs to be picked up in the code still to load the right page.

    here is my fail code that I come up with after hours of trying to learn and looking at other examples.

    RewriteEngine on
    RewriteRule ^~/$2/$3/? ~/productpage.php?productidpage=$1&brand=$2&productname=$3

    My frustration has reached extremes so I've come to the experts for help, I was hoping to go live with the site once this issue is solved.

    Please help..

    Much appreciated.

  • #2
    New Coder
    Join Date
    Apr 2011
    Posts
    59
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I think this should work:

    Code:
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    Options +FollowSymLinks
    
    RewriteRule ^/([^/]+)/([^/]+)$ productpage.php?productidpage=24&brand=$1&productname=$2 [L]
    Not sure if doing that will mess up your index page or not though....

  • #3
    New Coder
    Join Date
    Jul 2012
    Posts
    11
    Thanks
    1
    Thanked 1 Time in 1 Post
    Hey Kurisvo,

    Thanks for that, I put that into the .htaccess file but it had no effect.

    I also tested it on product 24 since the example you gave me was hard linked to that one.

    Any ideas?

    Where did you learn how to do this, are there any easy guides out there, most I've seen are below average in helpfulness for newbies.

  • #4
    New Coder
    Join Date
    Apr 2011
    Posts
    59
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Oops, I thought you wanted the 24 hard coded, my bad. My suggestion would be to try something using a mysite.com/something/ to see if the issue is that it's trying to call your index page by default. So something like

    Code:
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    Options +FollowSymLinks
    
    RewriteRule ^view/([^/]+)/([^/]+)/([^/]+)$ productpage.php?productidpage=$1&brand=$2&productname=$3 [L]
    which you could view by going mysite.com/view/24/Dymatize/SUPER+AMINO/

    Just see if that works and go from there?

    .htaccess isn't my strong suit, but some help is better then none :P

  • #5
    New Coder
    Join Date
    Jul 2012
    Posts
    11
    Thanks
    1
    Thanked 1 Time in 1 Post
    Kurisvo,

    thanks again buddy, looking at your code examples I am starting to get a grasp on what's going on.

    But I copy pasta'd your suggestion into my .htaccess file. Unfortunately it didn't do anthing . I put some random crap in the htaccess file just to see if it was reading it and yeah when I tried to load the site it threw out a white screen filled with errors.

    Do you have any more suggestions you can think of?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •