Follow Me on Twitter
Client Support Community Server Status Contact Us Client Login
Email Hosting Website Hosting Reseller Hosting VPS Hosting Dedicated Servers

    Join our Community      Check your private messages       Profile       Search       FAQ       Memberlist       Log in


Noupe

 
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
Z Reply with quote
 NetHosted Customer

 

 Joined: 29 Jan 2005
 Posts: 382
 

PostPosted: Sat Mar 13, 2010 1:17 pm    Post subject: Noupe
 
not sure if anyone else follows Noupe, they often have some useful articles and snippets. This one on mod rewrites explains it in some far simpler terms lol

http://www.noupe.com/php/10-mod_rewrite-rules-you-should-know.html

_________________
Getting the hang of it slowly (subject to comment)
Back to top
View user's profile Send private message
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Sat Mar 13, 2010 1:33 pm    Post subject:
 
Good reference

Here is another mod_rewrite cheat sheet: http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
Z Reply with quote
 NetHosted Customer

 

 Joined: 29 Jan 2005
 Posts: 382
 

PostPosted: Sun Mar 14, 2010 9:26 am    Post subject:
 
cool, still don't understand it all lol

in the pdf sheet they say:

Example: Nice looking URLs (no querystring)
# domain.com/category-name/ to domain.com/categories.php?name=category-name
RewriteRule ^([A-Za-z0-9-]+)/?$ categories.php?name=$1 [L]

is that right? Isn't the description of what it does the wrong way around?

_________________
Getting the hang of it slowly (subject to comment)
Back to top
View user's profile Send private message
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Sun Mar 14, 2010 1:10 pm    Post subject:
 
No that's right. You have to think how you want the domains to appear for users which is of the form domain.com/category-name/. So you would link to the category using that type of URL in your site code and you need mod_rewrite to seamlessly rewrite it so the actual php script does get called with the right query attached to it e.g. domain.com/categories.php?name=category-name

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
Z Reply with quote
 NetHosted Customer

 

 Joined: 29 Jan 2005
 Posts: 382
 

PostPosted: Sun Mar 14, 2010 1:35 pm    Post subject:
 
yes, but they say to create nice looking URLs and then their comment describes from/to and they are the wrong way around?
_________________
Getting the hang of it slowly (subject to comment)
Back to top
View user's profile Send private message
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Sun Mar 14, 2010 1:40 pm    Post subject:
 
Their comment is right too, you in your code write the nice looking URL the rewrite rule is there to convert it back to the actual long form. So it does go nice url -> plain url.

I can see where your confusion is arising as you as the end user are looking to use a mod_rewrite solution to give your site nice looking short urls but in order for mod_rewrite to do that you have to give it the shorter urls to start with so it can convert them to the normal long version.

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
Z Reply with quote
 NetHosted Customer

 

 Joined: 29 Jan 2005
 Posts: 382
 

PostPosted: Sun Mar 14, 2010 5:23 pm    Post subject:
 
okay, sort of makes sense lol

so in real terms you keep the plane url as they are now and this rewrite will show it differently in the browser as well as allowing them to use both formats if they typed it?

_________________
Getting the hang of it slowly (subject to comment)
Back to top
View user's profile Send private message
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Sun Mar 14, 2010 5:33 pm    Post subject:
 
Z wrote:
so in real terms you keep the plane url as they are now and this rewrite will show it differently in the browser as well as allowing them to use both formats if they typed it?


Not really. In your site code you need to link to the shortened/nice/clean version of url. The mod_rewrite module then will intercept a request for this url and convert it to the longer/less clean url and Apache will serve the page from the converted address e.g. the real/less clean url. All this is done seamlessly so in the browser URL bar it still shows the clean/short URL.

Both forms of the URL will work, the short one because it gets rewritten to the long form and the long form because it's the actual real address of where the script resides.

Thanks,

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
Page 1 of 1

User Permissions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

 
Jump to: