Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect help Static -> Dynamic

Redirecting Static Pages to Dynamic ones

         

Speedingorange

8:53 am on Jul 4, 2010 (gmt 0)

10+ Year Member



IM having problems redirecting some pages of an old store format to a new store.

I need the URL's to be 301 to the new URLS.
So far I have tried the following.
AN example of the redirect would be
from this page:
http://example.co.uk/products/start-avalon-barrier

To:
http://www.example.co.uk/barriers/avalon_barrier_system_linking

I have tried several versions of redirect and not had any success.

Any help would be much appreciated as there is some good google rank at stake.

Many thanks
James

[edited by: jdMorgan at 4:30 am (utc) on Jul 6, 2010]
[edit reason] example.co.uk [/edit]

g1smd

6:28 pm on Jul 4, 2010 (gmt 0)

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



Without code examples it's not possible to tell you what was wrong with that code...

Speedingorange

6:38 am on Jul 5, 2010 (gmt 0)

10+ Year Member



Sorry I will Post examples of my Htaccess,

This is the closest I got to success

RedirectMatch 301 ^/products/start-avalon-barrier(.*)$ http://www.example.co.uk/barriers/avalon_barrier_system_linking

although it results in a strange URL and an invalid page, the new url is almost correct bar it has "?_route_=products/start-avalon-barrier" added to the end.

[edited by: jdMorgan at 4:31 am (utc) on Jul 6, 2010]
[edit reason] example.co.uk [/edit]

jdMorgan

4:42 am on Jul 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Evidently, you have some other code that internally rewrites "static-looking" URL requests to one or more acripts, passing the "product" to the script(s) as a query string variable.

These two code functions are interfering with each other for one or both of two reasons: The code is being executed such that the internal rewrite is being invoked prior to the redirect, due to the configured module execution order on this server or due to the location of the internal-rewrite code (i.e. it is in a higher-level .htaccess or config file than the redirect code), and/or due to the mixed use of Apache mod_rewrite and Apache mod_alias directives.

Basic advice:

Do not mix the use of mod_rewrite (e.g. RewriteRule) and mod_alias (e.g. RedirectMatch) directives. If mod_rewrite is used for anything, then use it for everything.

Across all config and .htaccess files from the top-level config files down through .htaccess files in all subdirectory levels, put all of your external redirects first, in order from most-specific patterns and conditions (fewest URLs affected) to least-specific patterns and conditions (more URLs affected).

Follow all redirects with all of your internal rewrites, again in order from most-to-least specific.

I suggest putting access-control rules (if any) before your external redirects... There's no use redirecting unwelcome requests.

Jim