问题原文
原帖链接 · malcman · CC BY-SA 3.0
Wondering if there are any negative implications to using a redirect on my own domain as a kind as a URL Shortener.
I am often asked by folks creating printed documents for "short URLs". My predecessor did this by using a 301 Redirect. The practice seems wrong to me, but am not able to explain why.
社区高分解答
原帖链接 · WebElaine · CC BY-SA 3.0
The only real downside is that if you set up a lot of redirects, it can eventually start to be a load on your server. Since servers vary widely, along with traffic and code performance, there's no magic number as to how many redirects is too many. Anecdotally, I manage a website with ~ 220,000 pageviews a month and we typically have 200-300 vanity redirects in place along with over 800 other lines in .htaccess at any given time, with no performance issues. I've managed much higher-traffic sites without negative repercussions as well. If you're worried about the performance, take site speed measurements before and after adding a batch of redirects to ensure you're not impacting performance, but generally speaking unless you're on a low-performance shared host, you shouldn't see problems with these simple redirects. Simple one-to-one Redirects aren't very performance-expensive, as compared to something like a RedirectMatch which is where you typically start to notice more performance impact.
If you're using a CMS, I would suggest looking into whether or not there may be a plugin available to add this type of redirect. That way, you are empowering your marketing folks to set up their own redirects - and that way they will also be able to see what redirects already exist, as eventually people may forget what's already been set up. Plugins like this vary in quality and functionality - some do 302s, some 301s, some can also begin to have performance issues once you hit a critical load of redirects. But it will save you a lot of time versus manually editing your .htaccess file every time someone wants a new vanity URL.
A word of caution: it helps to set up naming conventions before you start setting these up. Decide up front whether you want to make all vanity URLs all-lowercase (since typing them in manually from a printed piece is simpler if they are all-lowercase) or whether you want to allow title case. Decide whether you want to prefer hyphens (seen as SEO-friendly and easy to find on mobile keyboards) or underscores (more old-fashioned but maybe they match your full URLs) and whether you have any hard character limits for how long a vanity URL is allowed to be.
Finally, something else that may be of use for these printed pieces: look into Google's UTM parameters. If anyone will at some point find it helpful or interesting to measure how many people actually type in a certain URL from a particular printed piece, have them set up a separate vanity URL for every print medium they use. So for example, you could have example.com/tx-offer which redirects to
example.com/offers/september/?utm_campaign=offer&utm_medium=print&utm_source=texas-magazine
and also example.com/ks-offer which redirects to
example.com/offers/september/?utm_campaign=offer&utm_medium=print&utm_source=name-of-kansas-magazine
so in effect they both go to the same landing page, but the utm_source and the other parameters tell you whether the Kansas magazine or the Texas magazine - perhaps with the same creative - sent more actual visitors to your website. This of course is only useful if you're measuring such things in Google Analytics, but it's fairly common and free to set up. This may in turn help people better understand which print pieces are more successful. This is another thing you want to standardize if possible before you begin - decide whether you want to stick with lowercase for convenience, or perhaps uppercase, to track your campaigns. You might even get more granular than "print" for media (magazine vs. newsletter, etc.) or you may want to group all "print" media to more easily compare them in one view. Even if you're not working on paid campaigns, it may help you determine where to spend more time and money - say postcards perform much poorer than your newsletter, so maybe you don't have web CTAs on postcards anymore.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
