phillystyle123
asked on
301 redirect with URL parameters
Hi,
I've just reworked my shopping cart and need to do a 301 redirect for pages that are passing url parameters so, if google presents this link:
http://minipharmacy.net/index.php?manufacturers_id=15
i need it to redirect to:
http://minipharmacy.net/prod1_man2.php?manufacturers_id=29
here's the rub - i can't have index.php simply redirect to prod1_man2.php because i'm only using prod1_man2.php to display products by specific manufacturers
I've just reworked my shopping cart and need to do a 301 redirect for pages that are passing url parameters so, if google presents this link:
http://minipharmacy.net/index.php?manufacturers_id=15
i need it to redirect to:
http://minipharmacy.net/prod1_man2.php?manufacturers_id=29
here's the rub - i can't have index.php simply redirect to prod1_man2.php because i'm only using prod1_man2.php to display products by specific manufacturers
ASKER
in which page? index.php?
Yes... Whatever your default index page is ...
@phillystyle123: Is there a translation necessary on the "id=" fields? Your OP showed translating id=15 on the old page into id=29 on the new page. Do you have a need for that? If so, tell us a little more about how you plan to effect the translation. Best, ~Ray
How to implement the 301 Redirect
1. To create a .htaccess file, open notepad, name and save
the file as .htaccess (there is no extension).
2. If you already have a .htaccess file on your server,
download it to your desktop for editing.
3. Place this code in your .htaccess file:
redirect 301 /old/old.htm http://www.you.com/new.htm
4. If the .htaccess file already has lines of code in it,
skip a line, then add the above code.
5. Save the .htaccess file
6. Upload this file to the root folder of your server.
7. Test it by typing in the old address to the page you've
changed. You should be immediately taken to the new
location.
1. To create a .htaccess file, open notepad, name and save
the file as .htaccess (there is no extension).
2. If you already have a .htaccess file on your server,
download it to your desktop for editing.
3. Place this code in your .htaccess file:
redirect 301 /old/old.htm http://www.you.com/new.htm
4. If the .htaccess file already has lines of code in it,
skip a line, then add the above code.
5. Save the .htaccess file
6. Upload this file to the root folder of your server.
7. Test it by typing in the old address to the page you've
changed. You should be immediately taken to the new
location.
Another:
1. To redirect ALL files on your domain use this in your
.htaccess file if you are on a unix web server:
redirectMatch 301 ^(.*)$ http://www.domain.com
redirectMatch permanent ^(.*)$ http://www.domain.com
You can also use one of these in your .htaccess file:
redirect 301 /index.html http://www.domain.com/index.html
redirect permanent /index.html http://www.domain.com/index.html
redirectpermanent /index.html http://www.domain.com/index.html
This will redirect "index.html" to another domain using a
301-Moved permanently redirect.
2. If you need to redirect http://mysite.com to
http://www.mysite.com and you've got mod_rewrite enabled on
your server you can put this in your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
or this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Tip: Use your full URL (ie http://www.domain.com) when
obtaining incoming links to your site. Also use your full
URL for the internal linking of your site.
3. If you want to redirect your .htm pages to .php pages
andd you've got mod_rewrite enabled on your server you can
put this in your .htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule (.*).htm$ /$1.php
4. If you wish to redirect your .html or .htm pages to
.shtml pages because you are using Server Side Includes
(SSI) add this code to your .htaccess file:
AddType text/html .shtml
AddHandler server-parsed .shtml .html .htm
Options Indexes FollowSymLinks Includes
DirectoryIndex index.shtml index.html
1. To redirect ALL files on your domain use this in your
.htaccess file if you are on a unix web server:
redirectMatch 301 ^(.*)$ http://www.domain.com
redirectMatch permanent ^(.*)$ http://www.domain.com
You can also use one of these in your .htaccess file:
redirect 301 /index.html http://www.domain.com/index.html
redirect permanent /index.html http://www.domain.com/index.html
redirectpermanent /index.html http://www.domain.com/index.html
This will redirect "index.html" to another domain using a
301-Moved permanently redirect.
2. If you need to redirect http://mysite.com to
http://www.mysite.com and you've got mod_rewrite enabled on
your server you can put this in your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
or this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Tip: Use your full URL (ie http://www.domain.com) when
obtaining incoming links to your site. Also use your full
URL for the internal linking of your site.
3. If you want to redirect your .htm pages to .php pages
andd you've got mod_rewrite enabled on your server you can
put this in your .htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule (.*).htm$ /$1.php
4. If you wish to redirect your .html or .htm pages to
.shtml pages because you are using Server Side Includes
(SSI) add this code to your .htaccess file:
AddType text/html .shtml
AddHandler server-parsed .shtml .html .htm
Options Indexes FollowSymLinks Includes
DirectoryIndex index.shtml index.html
I think we need more clarification from the OP. The HTACCESS writeup from servoadmin looks great, but in the OP, phillystyle wrote, "here's the rub - i can't have index.php simply redirect to prod1_man2.php because i'm only using prod1_man2.php to display products by specific manufacturers."
That statement, coupled with the example that showed different URL args, would seem to indicate to me the need for a translation table of some sort, and for that I would probably consider a PHP/MySQL script.
phillystyle123: Can you give us some guidance here?
Thanks, ~Ray
That statement, coupled with the example that showed different URL args, would seem to indicate to me the need for a translation table of some sort, and for that I would probably consider a PHP/MySQL script.
phillystyle123: Can you give us some guidance here?
Thanks, ~Ray
ASKER
Just getting back to this question - sorry for the delay.
I don't know what a "translation table" is - ray - do you have a url i might be able tocheck out
also - i'm starting the think that my course of action in this case would be to delete the outdated pages from the server and just use a custom error page - how long do those outdated pages stay in google's index?
I don't know what a "translation table" is - ray - do you have a url i might be able tocheck out
also - i'm starting the think that my course of action in this case would be to delete the outdated pages from the server and just use a custom error page - how long do those outdated pages stay in google's index?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Ray,
I think I'm going to go with the "Expires" option - so, if I use this approach, my outdated pages will expire? for instance what if I put Tues, 20 Jan 2009....will they expire the next time google is indexed?
I think I'm going to go with the "Expires" option - so, if I use this approach, my outdated pages will expire? for instance what if I put Tues, 20 Jan 2009....will they expire the next time google is indexed?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so then why use expire? oh - i think i get it. so, expire causes notfound page to load. right?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Ray - using your suggestions coupled with a little server clean up - I should be good to go.
Thanks for the points! Glad things are moving ahead, ~Ray
Open in new window