Jump to content
Sign in to follow this  
imgrooot

Rewriting pretty URLs. Too many examples out there don't show the entire process.

Recommended Posts

Say below is my normal html href link. How would you turn this into a pretty URL using .htaccess?  Also if I understand it correctly, this link will also have to be changed to match the pretty url.  What would the new link look like? 

<a href="shop.php?type=45&name=belts">Belts</a>

Share this post


Link to post
Share on other sites

What would the new link look like?

 

Designing the URLs is your job. “Pretty URLs” are just an abstract concept for URLs that are optimized for readability. How exactly your URLs should look like is something only you know. A good guideline is Cool URIs don't change from Tim Berners-Lee himself.

Edited by Jacques1

Share this post


Link to post
Share on other sites

Designing the URLs is your job. “Pretty URLs” are just an abstract concept for URLs that are optimized for readability. How exactly your URLs should look like is something only you know. A good guideline is Cool URIs don't change from Tim Berners-Lee himself.

 

I've been pulling my hair trying to figure this out and so far unsuccessful.  It would be very helpful if someone knowledgeable about this can help me out.  Every professional site I see out there has pretty urls, as oppose to what I have above.  Even phpfreaks site has pretty urls.  How would I go on about doing that based on the link I provided above?  So far all I got is this. How would I change the above link to match this?

RewriteRule ^([a-z]+)\/([0-9]+)\/?$ shop.php?type=$1&name=$2 [NC]

Share this post


Link to post
Share on other sites

This makes no sense. You're now assuming an alphabetical type followed by a numerical name, but your link above has the exact opposite (a numerical type and an alphabetical name).

 

Again: You have it backwards. You tell us your the URLs should look like. And then we can tell you how to implement them. Guessing from your example, it seems you want this:

/belts/45

So first the category, then the numerical type. Correct?

Share this post


Link to post
Share on other sites

This makes no sense. You're now assuming an alphabetical type followed by a numerical name, but your link above has the exact opposite (a numerical type and an alphabetical name).

 

Again: You have it backwards. You tell us your the URLs should look like. And then we can tell you how to implement them. Guessing from your example, it seems you want this:

/belts/45

So first the category, then the numerical type. Correct?

 

Well yes like that, although belts can come after the 45.  Like this.

shop/45/belts

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.