Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-01-2012, 05:49 AM   PM User | #1
dazamate
New Coder

 
Join Date: Jul 2012
Posts: 11
Thanks: 1
Thanked 1 Time in 1 Post
dazamate has a little shameless behaviour in the past
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.
dazamate is offline   Reply With Quote
Old 08-02-2012, 05:16 PM   PM User | #2
Kurisvo
New Coder

 
Join Date: Apr 2011
Posts: 59
Thanks: 8
Thanked 0 Times in 0 Posts
Kurisvo is an unknown quantity at this point
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....
Kurisvo is offline   Reply With Quote
Old 08-03-2012, 12:55 AM   PM User | #3
dazamate
New Coder

 
Join Date: Jul 2012
Posts: 11
Thanks: 1
Thanked 1 Time in 1 Post
dazamate has a little shameless behaviour in the past
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.
dazamate is offline   Reply With Quote
Old 08-03-2012, 01:36 AM   PM User | #4
Kurisvo
New Coder

 
Join Date: Apr 2011
Posts: 59
Thanks: 8
Thanked 0 Times in 0 Posts
Kurisvo is an unknown quantity at this point
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
Kurisvo is offline   Reply With Quote
Old 08-04-2012, 02:17 PM   PM User | #5
dazamate
New Coder

 
Join Date: Jul 2012
Posts: 11
Thanks: 1
Thanked 1 Time in 1 Post
dazamate has a little shameless behaviour in the past
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?
dazamate is offline   Reply With Quote
Reply

Bookmarks

Tags
apache, htaccess, permalink

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:27 PM.


Advertisement
Log in to turn off these ads.