Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Sanjeet
at 2024-01-06 13:02:38
Point:250 Replies:17 POST_ID:828872USER_ID:11781
Topic:
Hypertext Markup Language (HTML);;PHP Scripting Language
We are redirecting our old site to a new one and we need to use a 301 re-direct.
How can I accomplish this?
How can I accomplish this?
Expert: Ray Paseur replied at 2024-01-07 08:10:34
This is obviously untested, but it's correct in theory and shows the way you would use PHP to do this. The images/ directory should probably have a 301-redirect via .htaccess, and all of the files in the new images/ directory should have the same names as the files in the old directory.
<?php // RAY_temp_sanjeet.phperror_reporting(E_ALL);// EXAMPLE OF A MAPPING OBJECT FOR OLD TO NEW URLS$map = array( 'donor' => 'http://umtb.med.miami.edu/donor-services', 'services' => 'http://umtb.med.miami.edu/tissue-services', 'safety' => 'http://umtb.med.miami.edu/safety-and-quality', 'clinical' => 'http://umtb.med.miami.edu/clinical-services');// GET THE action= ARGUMENT$a = !empty($_GET['action']) ? $_GET['action'] : FALSE;// IF NO ACTION REDIRECT TO THE NEW HOME PAGEif (!$a){ header("HTTP/1.1 301 Moved Permanently"); header("Location: http://umtb.med.miami.edu/"); exit;}// IF NO KNOWN ACTION REDIRECT TO THE NEW HOME PAGEif (!array_key_exists($a, $map)){ header("HTTP/1.1 301 Moved Permanently"); header("Location: http://umtb.med.miami.edu/"); exit;}// IF A KNOWN ACTION REDIRECT TO THE NEW PAGE$url = $map[$a];header("HTTP/1.1 301 Moved Permanently");header("Location: $url");exit; 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:
Expert: Ray Paseur replied at 2024-01-07 07:55:22
Here are the URLs of the pages linked in the old site.
index.php?action=donorindex.php?action=servicesindex.php?action=safetyindex.php?action=clinicalindex.php?action=researchindex.php?action=tissueindex.php?action=contactindex.php?action=historyindex.php?action=community-educationindex.php?action=staffindex.php?action=donor-storyindex.php?action=partnershipindex.php?action=donor-faqindex.php?action=donor-faq-spanishindex.php?action=englishindex.php?action=evaluationindex.php?action=recoveryindex.php?action=processingindex.php?action=allograft-safetyindex.php?action=certificationindex.php?action=scientific-paperindex.php?action=patient_storiesindex.php?action=patient-faqindex.php?action=patient-faq-spanishindex.php?action=tissue-spanishindex.php?action=catelogimages/University%20of%20Miami%20Accreditation%20Extension%20Ltr%207%20_Dec%202013.pdfimages/Registration%20with%20US%20Food%20%26%20Drug%20Administration.pdfimages/Licensed%20by%20the%20State%20of%20Florida%20Agency%20for%20Health%20Care%20Administration%202013.pdfimages/State%20of%20California%20Exp%2008.17.2014.pdfimages/State%20of%20New%20York%2005.25.12%20to%2006.01.2016.pdfimages/State%20of%20Maryland%20Exp%2006.30.2013.pdfimages/State%20of%20Oregon%20Exp%203.20.15.pdfimages/State%20of%20Illinois%20Issued%2011.16.12.pdfimages/Licensed%20by%20Health%20Canada20130115153556073.pdfimages/Licensed%20by%20Health%20Canada%20TB%20Certificate%2020130115153612034.pdfimages/Tissue%20Bank%20Catalog-Final.pdfimages/RecallInformation.pdf 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:
Expert: Gary replied at 2024-01-07 07:46:14
Have you put it in the root folder of umiamitb.org
Are you accessing the old site by the domain name? You said you were testing this in a test environment
Are you accessing the old site by the domain name? You said you were testing this in a test environment
Expert: Ray Paseur replied at 2024-01-07 07:42:03
Since you do not have a 1:1 mapping of URLs from the old site to the new site, you might want to consider using the PHP strategy instead of .htaccess because it will give you more programmatic control over the redirect. Here is how I would do it.
Spider the old site and the new site.
Lay the results sets out side-by-side.
Make a logical connection between the old site URLs and the new site URLs.
If any old site URLs do not map perfectly to new site URLs, use the new site home page.
Write a small PHP script that does this:
Create a PHP object or array that maps the old-to-new URLs.
Detect the name of the requested page by examining the request and $_GET.
Choose the name of the new site URL from the PHP object.
Issue two header() calls, first for the 301, next for the new Location.
Once you have that script working, install it in place of the pages of the old site, which mostly seem to be accessed via index.php. There may be some other links you need to deal with manually, but the little PHP script will probably handle the majority of your requests, directing the browser to the correct place in the new site.
Spider the old site and the new site.
Lay the results sets out side-by-side.
Make a logical connection between the old site URLs and the new site URLs.
If any old site URLs do not map perfectly to new site URLs, use the new site home page.
Write a small PHP script that does this:
Create a PHP object or array that maps the old-to-new URLs.
Detect the name of the requested page by examining the request and $_GET.
Choose the name of the new site URL from the PHP object.
Issue two header() calls, first for the 301, next for the new Location.
Once you have that script working, install it in place of the pages of the old site, which mostly seem to be accessed via index.php. There may be some other links you need to deal with manually, but the little PHP script will probably handle the majority of your requests, directing the browser to the correct place in the new site.
Author: Sanjeet replied at 2024-01-07 06:42:44
I created a file in notepad called .htaccess
Pleaced the code in the location C:wwwUMTB:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*umiamitb.org$ [NC]
RewriteRule ^(.*)$ http://umtb.med.miami.edu/$1 [R=301,L]
When I launched the site it did not redirect.
Pleaced the code in the location C:wwwUMTB:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*umiamitb.org$ [NC]
RewriteRule ^(.*)$ http://umtb.med.miami.edu/$1 [R=301,L]
When I launched the site it did not redirect.
Expert: Ray Paseur replied at 2024-01-06 15:19:17
While you're working this issue, you might want to put a robots.txt file in the two sites to avoid further indexing any of the pages. You might also want to add a meta tag to every page in order to suppress indexing. As soon as the search engines (and the human clients) start getting 404's it will be troublesome. Making sure the redirect strategy works well is a very important issue.
Expert: Gary replied at 2024-01-06 14:00:01
So just create the file in notepad
Author: Sanjeet replied at 2024-01-06 13:58:05
I am trying to test this on the Test enviornment first.
Under WWW root there is folder with all the files for the site I do not find it in there and I did a search htaccess.
Under WWW root there is folder with all the files for the site I do not find it in there and I did a search htaccess.
Expert: Gary replied at 2024-01-06 13:47:30
In the root folder of your old domain - if it doesn't exist then just create the file (its possible you cannot see it because it is hidden)
Note it is .htaccess without a file name, just an extension
Note it is .htaccess without a file name, just an extension
Author: Sanjeet replied at 2024-01-06 13:44:51
WHere do I find the .htacccess file?
Expert: Ray Paseur replied at 2024-01-06 13:41:03
Here is what I might do. Create a mapping object that gives you a key of the old page name, and a value of the new URL. Example:
http://umiamitb.org/index.php?action=donor maps to http://umtb.med.miami.edu/donor-services
Then use a PHP script to detect the $_GET['action'] value and issue a 301 Moved permanently header, redirecting to the new URL. It won't take long for the search engines to pick up the redirection.
http://umiamitb.org/index.php?action=donor maps to http://umtb.med.miami.edu/donor-services
Then use a PHP script to detect the $_GET['action'] value and issue a 301 Moved permanently header, redirecting to the new URL. It won't take long for the search engines to pick up the redirection.
Expert: Gary replied at 2024-01-06 13:35:52
In the .htaccess on the old domain add this
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
and remove anything else.
This is assuming the same folder structure i.e.
www.olddomain.com/folder1/index.php
will be redirected to
www.newdomain.com/folder1/index.php
If you just want to redirect to the home page on the new site then remove the $1
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
and remove anything else.
This is assuming the same folder structure i.e.
www.olddomain.com/folder1/index.php
will be redirected to
www.newdomain.com/folder1/index.php
If you just want to redirect to the home page on the new site then remove the $1
Expert: Ray Paseur replied at 2024-01-06 13:34:40
By "structure," we mean the URLs of the pages. If you change the domain but do not change the URLs of the pages, you can get a 1:1 mapping from old to new fairly easily.
But it looks like the infrastructure of the site has changed. Example:
http://umiamitb.org/index.php?action=donor
http://umtb.med.miami.edu/donor-services
http://umiamitb.org/index.php?action=contact
http://umtb.med.miami.edu/contact
You might also want to check for validation.
http://validator.w3.org/check?uri=http%3A%2F%2Fumtb.med.miami.edu%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
But it looks like the infrastructure of the site has changed. Example:
http://umiamitb.org/index.php?action=donor
http://umtb.med.miami.edu/donor-services
http://umiamitb.org/index.php?action=contact
http://umtb.med.miami.edu/contact
You might also want to check for validation.
http://validator.w3.org/check?uri=http%3A%2F%2Fumtb.med.miami.edu%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
Expert: duncanb7 replied at 2024-01-06 13:32:56
Dear Sanjeet,
Could you try this on your .htaccess file ?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*umiamitb.org$ [NC]
RewriteRule ^(.*)$ http://umtb.med.miami.edu/$1 [R=301,L]
Duncan
Could you try this on your .htaccess file ?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*umiamitb.org$ [NC]
RewriteRule ^(.*)$ http://umtb.med.miami.edu/$1 [R=301,L]
Duncan
Author: Sanjeet replied at 2024-01-06 13:30:50
Old Site: http://umiamitb.org/
New Site: http://umtb.med.miami.edu/
Domain are different right?
Not sure what you mean by structure.
New Site: http://umtb.med.miami.edu/
Domain are different right?
Not sure what you mean by structure.
Accepted Solution
Expert: duncanb7 replied at 2024-01-06 13:29:39
250 points EXCELLENT
If you can provide more information to us, that will help us to answer it completely.
it seems you want to re-direct your site a to site b,
you can do that on editing .htaccess file under your public_html directory and put
the following statement into it
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*sitea.com$ [NC]
RewriteRule ^(.*)$ http://siteb.com/$1 [R=301,L]
Duncan
it seems you want to re-direct your site a to site b,
you can do that on editing .htaccess file under your public_html directory and put
the following statement into it
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*sitea.com$ [NC]
RewriteRule ^(.*)$ http://siteb.com/$1 [R=301,L]
Duncan
Expert: Gary replied at 2024-01-06 13:07:29
Is the structure the same?
Is the domain name the same?
If the domain name and structure is the same then you do not have to do anything.
Is the domain name the same?
If the domain name and structure is the same then you do not have to do anything.