Jump to content

redirecting 301 - How to


Recommended Posts

Hello

If i place the code below is my fresh generated .htaccess file i am getting an internal error.

What am i doing wrong?

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id_cms=4$
RewriteRule ^/cms.php$ 
http://multihout.nl/content/16-over-multihout [L,R=301]

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id_cms=2$
RewriteRule ^/cms.php$ 
https://multihout.nl/contact-form.php?fid=1 [L,R=301]

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id_cms=5$
RewriteRule ^/cms.php$ 
http://multihout.nl/content/7-veilig-betalen [L,R=301]

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id_cms=8$
RewriteRule ^/cms.php$ 
http://multihout.nl/content/11-veel-gestelde-vragen [L,R=301]

Link to comment
Share on other sites

OK, after viewing many hundreds of pages i finally found a solution for good 301 Redirecting. Too bad this info wasn't available on this forum and nobody replies at all. But hell.. here is the way you can do it..

Step 1
is to put off all your SEO configuration from you OLD and NEW site. Simply turn Friendly URL off in the Dashboard and generate a fresh .htaccess file.

Step 2
is to create a fresh text file.

Start the file with

RewriteEngine on



Then add the flowing code for every:

Category-page:

If my old page is: http://www.example.nl/shop/category.php?id_category=37
And my new page is: http://example.nl/category.php?id_category=1000

RewriteCond %{QUERY_STRING} ^id_category=(37)$
RewriteRule ^category\.php$ http://example.nl/category.php?id_category=1000 [L,R=301]



Product-page:

If my old page is: http://www.example.nl/shop/product.php?id_product=5
And my new page is: http://example.nl/product.php?id_product=151005

RewriteCond %{QUERY_STRING} ^id_product=(5)$
RewriteRule ^product\.php$ http://example.nl/product.php?id_product=151005 [L,R=301]



CMS-page

If my old page is: http://www.example.nl/shop/cms.php?id_cms=9
And my new page is: http://example.nl/cms.php?id_cms=7

RewriteCond %{QUERY_STRING} ^id_cms=(9)$
RewriteRule ^cms\.php$ http://example.nl/cms.php?id_cms=7 [L,R=301]



Index.php-page

If my old page is: http://www.example.nl/shop/index.php
And my new page is: http://example.nl/index.php

Redirect 301 /shop /




Step 3
Is to save the file just made to a .htaccess file and place it in the root of your OLD site!

(Your file should look like this:)

RewriteEngine on

RewriteCond %{QUERY_STRING} ^id_category=(37)$
RewriteRule ^category\.php$ http://example.nl/category.php?id_category=1000 [L,R=301]

RewriteCond %{QUERY_STRING} ^id_cms=(5)$
RewriteRule ^cms\.php$ http://example.nl/cms.php?id_cms=7 [L,R=301]

RewriteCond %{QUERY_STRING} ^id_product=(5)$
RewriteRule ^product\.php$ http://example.nl/product.php?id_product=151005 [L,R=301]



Step 4
Test if this configuration works for you. For me it works 100%!

Step 5
Don't activate your friendly URL's of your old site. BUT you can activate the SEO configuration of your new site and generate a new .ht-access file through the dashboard.

Finished

  • Like 1
Link to comment
Share on other sites

For the complete website to redirect end your .htaccess file (old website) with this code:

# Catch 404 errors
ErrorDocument 404 /shop/404.php

RewriteEngine on

# 404
Redirect 301 /shop/404.php /404.php

# BEST SALES
Redirect 301 /shop/best-sales.php /best-sales.php

# AUTHENTICATION
Redirect 301 /shop/authentication.php /authentication.php

# ADDRESS
Redirect 301 /shop/address.php /address.php

# ADDRESSES
Redirect 301 /shop/addresses.php /addresses.php

# ATTACHMENT
Redirect 301 /shop/attachment.php /attachment.php

# CART
Redirect 301 /shop/cart.php /cart.php

# REMAINING AND FORGOTTEN CATEGORIES
Redirect 301 /shop/category.php /category.php

# CONTACT-FORM
Redirect 301 /shop/contact-form /contact-form.php

# DISCOUNT
Redirect 301 /shop/discount.php /discount.php

# IDENTITY
Redirect 301 /shop/identity.php /identity.php

# MY ACCOUNT
Redirect 301 /shop/my-account.php /my-account.php

# NEW-PRODUCTS
Redirect 301 /shop/new-products.php /new-products.php

# ORDER-CONFIRMATION
Redirect 301 /shop/order-confirmation.php /order-confirmation.php 

# ORDER-DETAIL
Redirect 301 /shop/order-detail.php /order-detail.php

# ORDER-FOLLOW
Redirect 301 /shop/order-follow.php /order-follow.php

# ORDER-RETURN
Redirect 301 /shop/order-return.php /order-return.php

# ORDER-SLIP
Redirect 301 /shop/order-slip.php /order-slip.php

# PAGINATION
Redirect 301 /shop/pagination.php /pagination.php

# PASSWORD
Redirect 301 /shop/password.php /password.php

# PRICES DROP
Redirect 301 /shop/prices-drop.php /prices-drop.php

# REMAINING AND FORGOTTEN PRODUCTS
Redirect 301 /shop/product.php /product.php

# SEARCH
Redirect 301 /shop/search.php /search.php

# SITEMAP
Redirect 301 /shop/sitemap.php /sitemap.php

# SUPPLIER
Redirect 301 /shop/supplier.php /supplier.php

# MANUFACTURER
Redirect 301 /shop/manufacturer.php /manufacturer.php

# INDEX
Redirect 301 /shop/index.php /index.php


Link to comment
Share on other sites

  • 6 months later...
  • 9 months later...

im trying to redirect OLD_CATEGORY to NEW_CATEGORY with

 

Redirect 301 /10-jim-shore-s-disney-traditions /4_jim-shore
or
Redirect 301 10-jim-shore-s-disney-traditions /4_jim-shore

 

it's not working until i try with dual slashes

www.domain.tld//10-jim-shore-s-disney-traditions

and i get the new url.

 

But every time i try with normal single slash (/) y got 404.

 

Any clues?

Edited by bicyus (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...
×
×
  • Create New...