homepage Welcome to WebmasterWorld Guest from 54.226.252.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
URL Rewriting
url rewriting
neostar




msg:4080271
 4:03 am on Feb 15, 2010 (gmt 0)

Hello friends, i want one of my site to be url rewritten.
i m not noob in this, but want ur opinion abt this what is im doing right or wrong?

Current case:
suppose i have a site example.com which is mobile content download site

how it works as first it show category, and sub cats and subsub cats so the current url of my working site is

www.example.com/index.php?do=showCat&catID=1&doEngine=postComment

so i apparently have three arguments 1) do, 2)catID and 3) doEngine

Now,
Q-1: i want it to rewrite as

exmple.com/video/1

where video is category with catID=1,

so how do i reformate it with www.example.com/index.php?do=showCat&catID=1&doEngine=postComment to exmple.com/video/1

i mean i dont want to show the arguments like do and doEngine?
so is it possible, ahh i mean how do i do that?

i want to use the catID (which is numeric), so i can get it fetched from db, instead of catName which can contain spaces , puntuations etc so i dont want it as reference to do fetching from db, so what to do next?


Your help is greatly appriciated.
Thanks

 

jdMorgan




msg:4080474
 1:51 pm on Feb 15, 2010 (gmt 0)

You need to modify the script that generates the links that appear on your pages so that it produces the "SEO friendly" static URLs like /video/1. Links on your pages *define* the URLs, and mod_rewrite cannot change your page content.

Aftr changing your on-page links, you will then add a rewriterule to internally rewrite (not redirect) client requests for those 'friendly/static' URLs to the dynamic script filepath required to generate the correct page for that URL.

Having done both of these steps, you can optionally add a second rule that redirects only direct client requests for the 'old' dynamic/unfriendly URL to the new friendly/static URL. But this is an optional third step, and will not solve your main problem.

If you need to show "CatName" in the URL, then you'll need to do everything except the internal rewrite inside your script: Without scripting support, mod_rewrite does not have access to your database, and so cannot 'translate' a CatName to a CatID or vice-versa.

More details in this thread [webmasterworld.com] in our Apache Forum Library.

Jim

neostar




msg:4080688
 6:36 pm on Feb 15, 2010 (gmt 0)

@djMorgan, i got what u said, i know i have to reformate the internal link, which is not the issue, but there is i cant decide one thing

the current scenario is, that i m getting category from category ID, after url written done i still want category to be fetched from category id(bcos its going to be increase as time grows, ) so my current site look like this :

example.com/index.php?do=showCat&catID=1$pageNo=5$doEngine=comment

thie above url in my site produces as below(assuming cat ID = boelongs to Video (it is cat name)) with pageNo=1 appended to it:

Welcome to Video section:
>> New Videos
>> Uploaded Videos
>> etc etc..

but i want thing to be done as:

example.com/video/1

where : video=the cat name and 1= page no

the problem is i have multiple do arguments, like somethime do=schoCat and some thime its do=showSubCat

so how do i eliminate the "do" and "doEngine" arguments with being used?

or i have to use like:
exaple.com/showCat/video-1/5/comment

where: showCat=do, video=cat name, 1=cat id and comment=doEngine

help me , i m stuck in getting best(faint):
Great Thanks

jdMorgan




msg:4080707
 7:10 pm on Feb 15, 2010 (gmt 0)

> so how do i eliminate the "do" and "doEngine" arguments with being used?

You probably cannot eliminate them completely, because if you did, then the rewriterule would have no idea which script parameters to add, or what their values should be. The "new" URL must contain all of the information (but not necessarily all the text or the same text) as the old URL.

For example, you could shorten "showcat" and "showprod" to "sc" and "sp", and since the last 'thing' in the new URL is always a "doengine" parameter, you could just leave that alone.

example.com/sc/video-1/5/comment -> /index.php?do=showCat&catID=video-1&pageNo=5&doEngine=comment

RewriteRule /sc/([^/]+)/([0-9]+)/([a-z]+)$ /index.php?do=showCat&catID=$1&pageNo=$2&doEngine=$3 [L]

Jim

neostar




msg:4080726
 7:43 pm on Feb 15, 2010 (gmt 0)

Thanks 4 undrstanding what i said, ok then i'll use like
example.com/showCat/video-1/5

still a question, so what url schema u prefer to be 4 seo?
1) example.com/showCat/video-1/5

2) video.example.com/showCat/1/5

3) example.com/video/showCat/1/5

or the change of args doesnt affects the SEO at all?

Thanks.

jdMorgan




msg:4080827
 10:40 pm on Feb 15, 2010 (gmt 0)

That depends on whether "video-1" is "real" or not. If it is actually a video title that someone might search for, then it might be useful to put it first in the URL-path.

I consider keyword-in-URL to be a fairly "weak" SEO factor, but it is a strong "click-through" factor, since the keywords get highlighted (bolded) in search results.

Again, you can shorten "ShowCat" to "sc" -- I doubt that anyone searches for that, except perhaps cat-fanciers (and I doubt that's your main market).

Jim

neostar




msg:4080967
 2:16 am on Feb 16, 2010 (gmt 0)

lol, cat-fancier is not my main market. Mate i have got an idea, If i only use catname for fetching data?
Ie,
example.com/video
alternate to example.com/index.php?CatName=video
yeah, i also need to modify script, @djMorgan, mate so u bet on what i said?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved