htaccess VS safe redirect manager - wordpress

I'm updating a WP theme, changing permalinks, and also migrating to https at same time. Have 1 wildcard redirect (removing categories from URL) and about 140 manual redirects (old joomla links). Need advice between going with htaccess or Safe Redirect Manager. My only concern is page load speed, not extensible features or tracking.
It would seem like htaccess would always be the fastest but my htaccess file is 20kb (because of all the manual redirects). And so I wonder if loading a php plugin on every request (however all redirects intelligently cached) is faster. SRM might seem like the better option considering all the manual redirects but I'm wondering if there are some old-school htaccess phreaks who might say otherwise. I don't want to go through the hassle of testing.

The best solution would probably be to put your redirects in the main Apache config. Then this is only processed once when the server is started, rather than a 20kb htaccess being parsed for every request. As for your other option, not sure on the performance impact.

Related

First GET request too slow (wordpress)

I am running a VPS with multiple wordpress installations on it. When I access my website, the first request that the browser performs is a GET request that takes about 10 seconds to complete, then the css, js files and so on start to be downloaded as fast as one could expect. That slows down my website a lot.
I am running apache2 and php5 with default configurations, plus the following plugins in use:
Wordpress ZenCache.
php's APC cache.
mod_deflate.
The websites are just landing pages with minimal templates, nothing huge. When pages are cached, the previous time can be improved up to 2 or 3 seconds as much.
I understand that many wrong things could make this happen, but could anyone expert devise a possible starting point to fix?
By the way, I had to set up some aliases and redirections with mod_alias and mod_rewrite, I would like to know if that may cause this behaviuor as well.
After following Andrew's advice, I disabled the default reverse DNS lookups in my virtual hosts configuration file by adding the option
HostnameLookups off
In addition, I disabled the use of symlinks when possible with
<Directory /> Options -FollowSymLinks </Directory>
And disabled the logs as well. Now the problem has been solved and everything works much faster now. It was not directly related to Wordpress since a simple html landing page was also suffering from this latency.

Many 1000s of URL redirects in Drupal 7: PathAuto/GlobalRedirect, apache .htaccess, or another solution?

I am looking for the 'best' (fastest, most efficient) way to map http requests when there could be as many as 30,000 different URLs that need mapping.
I have made a map pointing URLs on the old vBulletin system to the URLs on the new Drupal 7 system.
My question is how to do the rewriting. I cannot use Apache mod_rewrite and RewriteMap since my server admin does not allow it. I prefer not to write a custom module. So I am looking for the best (most scalable) Drupal module or another solution.
I would assume PathAuto and Global Redirect would be the way to go but I want to know if there are scaleability issues with so many URLs in the map.
Apache mod_rewrite's RewriteMap reads the map and stores in memory until the file's mtime is changed -- does Global Redirect do that?
Edit: I do not have access to use Apache's RewriteMap directive, but I could place the redirects in an .htaccess file -- would that be cached in memory, or looked up on each request?
Thanks!
Turns out there is no problem with tens of thousands of URL aliases using the modules
Redirect
Global Redirect
PathAuto
I imported the aliases with Redirect Import (but ran into file upload size limit).

Permanent redirect issue after database corrupted

Here is the situation: I took over a WordPress project, which turned out to have a corrupted database (wp_terms table missing among other problems) for a while. While all posts appeared to be assigned to a category, they actually weren't!
Result: A ton of 404s we're created because url/category/something/post-slug was actually only accesible via url/post-slug. Ouch!
There were a lot of content changes in the past and after the SEO company discovered the 404s (after months), they ask me to set 301s for all posts.
I have now completely rebuild the database locally, imported posts/pages etc. and would like to assign the posts back to its categories. What's the best way to do so? I assume I cannot simply remove the permanent redirects because Google probably has indexed the pages already!?
Should I basically set permanent redirects for the permanent redirects?
For some reason I cannot believe its best practice but lets see what you guys think!
Its really bad practice to use chains of 301 redirects, but sure it kind of happens some times. If you want you can try the other way around and use the canonical option or 302 redirects so if you need to do another redirect in the future not to bug the chain with a third level of 301 redirect. Here is a post that compares the two ways :
Site Performance: rel=canonical vs redirect 301

SSL and relative URLs in site links and redirections

I have been working on a website in beta phase for some time now, and am finally about to launch it. There are several links, anchor tags, with relative URLs throughout the site that link to the admin and cart sections of the website, and now they have to be SSL secured.
Also, same question for relative URLs in Response.Redirect("~/../..");
When a user is browsing over http, is there anyway to redirect them to a page with https connection using a relative URL? It seems like poor practice to code absolute URLs for links and redirections for the purpose of SSL. If the domain name changes, I have to rewrite them all. Plus, if I want them to work on my localhost, I would have to change them every time I upload to server. There must be some solution.
Switching Between HTTP and HTTPS Automatically is a very good code to use for the implementation of switching logic fast and easy - and not change your existing code.
Similar: Preparing my ASP.NET / MVC site to use SSL?
These helper methods by Rick Strahl will help you
http://www.west-wind.com/weblog/posts/2007/Sep/18/ResolveUrl-without-Page
Pay special attention to ResolveServerUrl.
Depending on what version of IIS you are running, you could always offload this functionality to the webserver. Check out the URL Rewrite module here.

ASP.Net - Url Forwarding with Rewriting

I am developing a web site that uses a CMS and my actual home page is at mydomain.com/cms/home.aspx
When a user visits mydomain.com/index.aspx how to do I forward the site visitors to mydomain.com/cms/home.aspx?
One way is to create a dummy index.aspx with redirect to mydomain.com/cms/home.aspx but just wondering if there is a better way to do... may be in web.config or somewhere else!
Thanks
Sid
Redirects: How to redirect a URL path in IIS?
Rewrites: http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/
Both are a bit of learning, but can be achieved in a reasonable amount of time.
You always have the option of writing your own. For rewrites, you can write an HTTPModule (or update your CMS's rewrite module). For redirects, you can use a custom 404 page to handle redirects. I have done both for DotNetNuke. Rolling my own took about 16 hours, but handles a few hundred thousand of each efficiently with caching.
<redirect url="index.aspx" to="~/Pages/1/home.aspx"></redirect>

Resources