Forum Moderators: phranque

Message Too Old, No Replies

Pages redirection 301

Moving to new pages

         

axelf

11:53 am on Jun 15, 2009 (gmt 0)

10+ Year Member



Greetings,
Please help.
I need a redirection rule 301 - moved permanently (for search engine).

My current links looks like:
www.mydomain.com/postt859.html

and I need it to redirect to new:
www.mydomain.com/forum/viewtopic.php/t,859

The number 859 is variable.

What code I need to insert in .htaccess? I have no idea how to do it myself.
Many thanks in advance.

AnkitMaheshwari

12:20 pm on Jun 15, 2009 (gmt 0)

10+ Year Member



If you are doing this for the search engines, I would say that it would not be very good idea considering that www.mydomain.com/postt859.html URL is much better than www.mydomain.com/forum/viewtopic.php/t,859 as far as Search engine's crawling is considered.

g1smd

12:28 pm on Jun 15, 2009 (gmt 0)

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




Things to consider. Is the new site on the same domain? on the same host?

Have you changed to a new software package to run the site? Has the internal filepath changed as a result of that?

What internal filepath inside the server is the content really located at? Please provide details of the internal filepath (Note: a filepath is NOT a URL).

I don't understand why you want to redirect from a 'simple' URL to a 'complex' URL. Maybe you are needing a rewrite instead. Please carefully answer *all* of the above questions.

There are several thousand prior examples of the code you need here in this forum. Do not even think about code until we have gotten the exact requirements defined first.

axelf

1:28 pm on Jun 15, 2009 (gmt 0)

10+ Year Member



Its the new site on the same domain and host.
I am changing the software package (CMS + upraged forum). I changed the dir for forum from: /home/user/www.mydomain.com/modules/Forum to /home/user/www.mydomain.com/forums

I know that this new URL is complex, but better I cant get with this CMS (Joomla,Jfusion,PHPBB3).
It would be perfect to stay the same, only with added dir like: www.mydomain.com/forum/postt859.html but I think its not possible.
The old rule was: RewriteRule ^post(p¦t)([1-9][0-9]*).* modules.php?name=Forums&file=viewtopic&$1=$2

axelf

11:07 am on Jun 16, 2009 (gmt 0)

10+ Year Member



For the begining it would be much better to do just the R301, as I mention at the first post, due to lost links from search engines.

jdMorgan

1:14 pm on Jun 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer to your direct question is

RewriteRule ^post([a-z])([0-9]+)\.html$ http://www.example.com/forum/viewtopic.php/$1,$2 [R=301,L]

This assumes that you've already got other working mod_rewrite code in the .htaccess file.

Place all redirects ([R=301,L]) ahead of all internal rewrites ([L]) and put the two groups of rules in order from most-specific to least-specific patterns and conditions.

See the references cited in our Apache Forum Charter for more information.

Jim

axelf

2:06 pm on Jun 16, 2009 (gmt 0)

10+ Year Member



OK, I know what you mean,
thank you very much. I will try it.

g1smd

7:57 pm on Jun 16, 2009 (gmt 0)

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



Thanks for carefully answering the questions, as that allowed the correct answer for the correct question to be answered. :)