Forum Moderators: phranque

Message Too Old, No Replies

Perm 301 redirect for Dynamic URL

Need help to redirect dynamic Url

         

jpservicez1

8:44 pm on Jul 7, 2008 (gmt 0)

10+ Year Member



I need help to create a perm 301 redirect for my dynamic urls..using .htaccess

example

old dynamic url = www.example.com/example.php/number/catid/catname/subcatid/subcatname/articletitle

new dynamic url = www.example.com/newfolder/example.php/number/catid/catname/subcatid/subcatname/articletitle

Please what should the redirect code be in .htaccess.

Thanks

jdMorgan

9:28 pm on Jul 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Neither of those are what are usually called "dynamic URLs."

Since that is the case, I'll refer you to the Apache mod_alias and mod_rewrite documentation for examples.

Jim

g1smd

2:27 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are you sure that your URLs need to be that complex?

Using a rewrite, several of those elements could be removed from externally-promoted URLs, the rewrite connecting the new "short" URLs with the longer internal filepath, without exposing what that filepath actually is.

jpservicez1

2:37 pm on Jul 8, 2008 (gmt 0)

10+ Year Member



g1smd,

i like you suggestion but couple of questions/point

1] does this mean if i rewrite url to a short one google will have to re-crawl my site..160k urls
2] how long will this take
3] implication on SE ranking and current url have keywords in them
4] are there any gain over a short url to a long one..
5] urls have already be taking = backlinks...

what do u think...

g1smd

2:46 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Be clear on the difference between a rewrite and a redirect.

An internal rewrite takes an external request for a URL, translates that in to an internal filepath, and grabs that content without exposing that internal filepath to the outside world.

An external redirect tells a browser to make a new request for a different URL. The new URL is the one that will get indexed by search engines.

.

You can't "rewrite URL to a short one". That would be a redirect. A request for one URL is redirected to a different URL.

You already asked about redirecting a long URL to an even longer URL.

I am suggesting that you use "short URLs" on your site, and have short URLs in all the links on your site.

The short URLs would be rewritten by .htaccess to pull content from the longer internal filepath, without exposing what that internal filepath actually is.

Requests for the old, long, URLs would be redirected to the new, short, URLs, preserving traffic that still requests those old URLs, and transferring (most of the) PageRank over to the new URLs.

It's a lot of work for a long term benefit. There is a short-term dip (sometimes a few months long) in traffic while the changeover is reindexed.

Messing this up can totally destroy your indexing and ranking. You get one (ONE) chance to get it right.

g1smd

2:51 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, your entire site would have to be recrawled if the pages have new URLs.

However, going back to your very first question. You asked for a redirect.

Your redirect would call for all new URLs for the pages of the site anyway.

Are you sure that is what you wanted?

I now suspect that what you want to do is keep all the URLs the same, but your site is now housed in a different folder on the server to the one that it used to be in.

In that case you need the pages of your site to have links on them with the same URLs as they have always had. You will then need an internal rewrite to take those URL requests and translate them into the new internal filepath for the content. The content is then pulled from there, without exposing to the browser what that internal filepath actually is.

That's a rewrite, rather than the redirect that you originally asked for.

.

In that case the original question would have been:

My old site was stored on the server in this path:
/example.php/number/catid/catname/subcatid/subcatname/articletitle

The URLs indexed by Google are like this:
www.example.com/example.php/number/catid/catname/subcatid/subcatname/articletitle

I need to keep the URLs the same, but my content is now stored on the server in a different place:
/newfolder/example.php/number/catid/catname/subcatid/subcatname/articletitle

How do I do that?

.

Terminology is key here:

- rewrite vs. redirect

- URL vs. internal filepath

Only when we know what the question actually is, can the right answer be supplied.

In general:

- we can redirect one URL request over to another URL, and

- we can rewrite a URL request to an internal filepath.

The two things only differ by the inclusion of both an [R=301] and the target domain name in the RewriteRule for the redirect - and by the lack of both of those things for the rewrite.

jpservicez1

3:30 pm on Jul 8, 2008 (gmt 0)

10+ Year Member



g1smd,

wow..am trying to get my head around this but the background here was that i created mobile pages for my articles and they are now place in a new folder.

This means the original mobile pages url are showing error code 404. But if you include the new folder name in the old url it works. hence me wanting to do a redirect from the old [not working url] to the new one [including new folder name in url]. An yes you are right, the new url is longer.

regarding short url vs long one. i wasn't thinking in that context but was wandering the implications and impact. but i will keep that for future to do list.

but seriously to my question [3] & [4] what would you say.

g1smd

3:52 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would say again, do you really want the new URLs to be the ones indexed, dropping all the old URLs, and with it their History, their PageRank, their Age, their Trust, their Traffic?

If so, then you need a redirect from the old URLs to the new URLs. At that point, none of your old URLs will serve content any more, and will be dropped by search engines. However, at the same time, I would shorten those new URLs too (using a rewrite to connect a short URL to the real internal filepath).

If you want the old URLs to stay indexed, then you need a rewrite to connect the old URLs to the new internal filepath for that content.

The old URLs are already indexed by Google, etc. I expect you want to keep them the same.

Which URLs appear in the links on the new site, the old ones or the new ones? The links on your pages define the URLs that Google, etc, will try to be indexing. However they will also still be re-crawling all the URLs that they already know about.

You would be better off with a rewrite to connect the already indexed URLs with the new internal filepath on the server. The rewrite does not expose what that filepath is.

jpservicez1

4:05 pm on Jul 8, 2008 (gmt 0)

10+ Year Member



Yes i want the new URLs indexed.

I have already setup a redirect from the old urls to the new urls.

The old urls don't exist anymore on my site anywhere.

g1smd

4:35 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's the point. Your internal folder structure doesn't have to be reflected in the URLs that your site responds to.

It would have been quite easy to keep the same URLs and have a rewrite which connected the old URL requests with the new internal folder structure, without revealing what that new folder structure actually was.

In other words, no new URLs, and no change to the site as far as any of your visitors, or bots, were concerned.