Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Old 07-05-2011, 09:01 AM Rewrite
Experienced Talker

Posts: 34
Trades: 0
i asked my host tech support to redirect about 50 old urls


like

domain.com/old-page1.html to domain.com permanent

domain.com/old-page2.html to domain.com/new-page.html permanent

etc...

they first put in a broad redirect so that anything

domain.com/sdfb,asfb
domain.com/waiuerylrhaw.khakha.kgn

would redirect to

domain.com/

[i think, but not sure] the broad redirect interfered with some of my code and caused some errors, so I asked them to use a different approach redirecting only my specified urls.


they told me to manually do it my self in cPAnel

so I did, one at a time entered all the redirect

now in my htaccess file all the rules are there



RewriteCond %{HTTP_HOST} ^doamain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.doamain.com$
RewriteRule ^articles\/popup\/Gut5\.html$ "http\:\/\/domain\.com\/" [R=301,L]


but alot of them do not work



my host said it is because I have too many rules


any solutions of how to do this right?
BobMane is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-05-2011, 11:35 AM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Hmm, 50 individual lines in .htaccess is a bit much.


Bit more information needed.

Are there any patterns that can be matched between old url and new url?

Are these simply pages that have been removed from the site?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-05-2011, 12:01 PM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
oops


actually it is about 100 redirects...not 50


Are there any patterns that can be matched between old url and new url?

you mean so that I could reduce the number of redirects? not exactly

but here are a few:

domain.com/harder/HARDER_Productions.html
domain.com/harder/COVERPOP.html

new equivalent would be:

domain.com/harder.html

--

domain.com/mix-it-universal/index.html
domain.com/mix-it-universal/tell-us-what-u-want-milar.html

new equivalent would be:

domain.com/mix-it-universal.html


domain.com/articles/acoustics.html
domain.com/articles/guitar.html

new equivalent would be:

no equivalent (except maybe domain.com/blog)



Are these simply pages that have been removed from the site?



no this is a entirely new site. it is a re-launch going from a mostly static 10 years old website to a magneto store.

the old urls have a lot of incoming links form being on the web for 10 years so I have to redirect them to the magneto site.
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-05-2011, 12:59 PM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I would suggest the best way of handling this is with a custom 404 script. Magneto is already something of a resource hog and 100+ lines of .htaccess being parsed on every request isn't going to make it less so.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-06-2011, 12:10 AM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
any tips on how i would do that?
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-06-2011, 05:03 AM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Make an array of the old urls and new urls, sompare the error page then redirect.

this is coded in ASP but will convert to PHP fairly simply.

Might even do it myself today if time permits.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 07-06-2011 at 09:38 AM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-06-2011, 09:20 AM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
that would be great, I am kind of stuck on this
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-07-2011, 08:55 AM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Ok got distracted yesterday with a visit from the two week old newest family member

taken a bit longer than anticipated (PHP skills have a little more rust than I thought) But with a bit of RTFM we'll get there.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-07-2011, 11:20 AM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
I have attached the entire htaccess file for this Magento website
Attached Files
File Type: zip entire.htaccess.zip (1.9 KB, 1 views)
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-08-2011, 09:11 AM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Eventually! I'd get a lot more done if it wasn't for the clients

PHP Code:
<?php

// list of URIs to be handled and redirected.
//$pageArray['old uri'] => 'new uri'

$req=$_SERVER['REQUEST_URI'];
$pageArray = array('/old.php' => '/new.php');

if (
array_key_exists($req$pageArray)){
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: '.$pageArray[$req]);
} else {


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
This is the 404 page
<br>

<?php echo($_SERVER['REQUEST_URI']); ?>


<body>
</body>
</html>

<?php }; ?>
The URIs go in an associative array and you simply check if the old URI exists as a key, it then redirects to the associated value, if not it drops through to the else and displays an error page and throws a 404 response.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-08-2011, 09:13 AM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
save as 404.php and set a .htaccess directive for

ErrorDocument 404 /404.php
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-08-2011, 10:59 AM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
i appreciate the help but the solution instructions are way above my head.
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-08-2011, 11:38 AM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Ok

The only line you need to change is this one;
PHP Code:
$pageArray = array('/old.php' => '/new.php'); 
and you need to add more of them, one for each URI to redirect, like so:

The old URL is first
PHP Code:
$pageArray = array('/asdf.php' => '/zxcv.php');
$pageArray = array('/folder/1234.php' => '/newfolder/1890.php');
$pageArray = array('/old3.php' => '/new3.php');
$pageArray = array('/older.php' => '/newer.php'); 
If they are in folders, that must be added too as in the second example.

the URLs is going to be the address without the protocol (http://) and without the hostname (www.domain.tld).


And the .htaccess line of code is exactly as it is in the post. Leave everything else alone because that's written by Magneto.

In the 404.php page remove the code between the </head> and <body> (that's just my testing code)
Then in the body section you can put a link to your site map, a search box or whatever suits.

Does that help any?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-08-2011, 12:05 PM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
are you saying put a file I create from scratch at root

/

404.php

??

is this normal in a magento system?
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-08-2011, 12:54 PM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yep but you can call the file anything you want, just as long you use the same file name in htaccess for the error doc. I just call them 404.ext for file management purposes.

It's nothing at all to do with Magneto or any other CMS/Cart/Blog/Forum etc it's there to catch missing page requests, and you simply turn it's normal function to your advantage.

I have an entire site that relies ENTIRELY on a custom 404 page to serve the appropriate page.

Provided you return the correct response code to user agents you can do anything you like with them.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-08-2011, 01:03 PM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
OK I will look into this and try it out + post back..Thanks!
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-09-2011, 10:22 AM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
still don't get it:

this

PHP Code:
 <?php 

// list of URIs to be handled and redirected. 
//$pageArray['old uri'] => 'new uri' 

$req=$_SERVER['REQUEST_URI']; 
$pageArray = array('/old.php' => '/new.php'); 

if (
array_key_exists($req$pageArray)){ 
    
header('HTTP/1.1 301 Moved Permanently'); 
    
header('Location: '.$pageArray[$req]); 
} else { 


?> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
<head> 
<title>Not Found</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
</head> 
This is the 404 page 
<br> 

<?php echo($_SERVER['REQUEST_URI']); ?> 
 

<body> 
</body> 
</html> 

<?php }; ?>
goes where / into what document?


so there are 3 docs in play?

1. this php in some doc
2. a fake 404 page?
3. htaccess modification?
BobMane is offline
Reply With Quote
View Public Profile
 
Old 07-09-2011, 12:23 PM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
only ONE page (.htaccess) will need changing, the other is a new document.

The php code above, goes into a new document which is going to become the "Not Found" or 404 Error document for the entire website, not simply for Magneto, which is why I named it 404.php simply so you know what it does.

Then you add your list of redirects into the array.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-09-2011, 12:25 PM Re: Rewrite
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
BTW. It is not a FAKE 404 page, it really IS your 404 page, just getting a bit more use that's all.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-09-2011, 03:08 PM Re: Rewrite
Experienced Talker

Posts: 34
Trades: 0
Quote:
Originally Posted by chrishirst View Post
BTW. It is not a FAKE 404 page, it really IS your 404 page, just getting a bit more use that's all.

OK i get it. do you happen to have seen this work using a magneto site? (as you know magneo is a bit different)

also, it has its own /errors directory with htaccess, local.xml and phtml pages.
BobMane is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Rewrite

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.71993 seconds with 13 queries