-
Posts Tagged ‘Apache’
Knowledge Nuggets
Friday, January 20th, 2012 by Christian MattixAnyone who has done development, design, or IT knows that over the course of working on a project, you collect various “nuggets” of knowledge that you ever learn or find. Here I’m going to share some of what I’ve discovered that may be able to help you in your own projects. I have cited the original source of the information if I have that available. If there is something that I’ve left out, feel free to add it in the comments.
“Fatal error: Out of memory…” occurring when PHP and Apache memory limits seem fine
This problem drove me crazy for a little while. I did everything that I thought I needed to do, I changed the php.ini file to increase the php memory available until I ran across this link which provided the answer. We are using WiredTree as our hosting provider, for their servers, the problem was fixed by simply adding:
RLimitMem 128000000to the .htaccess file in the www root directory. After doing this, it fixed everything.I keep getting Notice: Undefined offset: 1 in views_block_view() in Drupal 7
After doing a bunch of operations during prototyping a Drupal 7 site we kept this error. There wasn’t anything that we seemed to be able to do to eliminate it from the Drupal administrative interface. After searching the web for quite some time I came across this page: http://objitsu.com/node/29 which gave me all of the information I need. From the article:
It’s caused by stale records in the block table that then fail to resolve. There’s plenty of reading material out there and suggested fixes etc. that I am sure work but once I knew what the problem was I applied *my process* for all Drupal problems like this.
- Find the code that issues the message..
- Trap the code and drupal_set_message() the offending item
- Use that information to fix-up the database / code as required.
Here’s how the fix works for this particular problem. In my case I edited views.module, line 569, here’s the code that was causing the notice to be show:
list($name, $display_id) = explode('-', $delta);
and here is what I added to the code to find out what the duff delta in question was…
if (count(explode('-',$delta)) == 1) { drupal_set_message($delta); } list($name, $display_id) = explode('-', $delta);
All I did then was refresh the page, take a note of hash value that was displayed and then cutting-and-pasting it into a command line MySQL session I issued this query:
mysql> DELETE FROM block WHERE delta = 'd98a0bfa5a33e7d8bab0fc0670bdc9fd'; Query OK, 4 ROWS affected (0.01 sec)
Which took out all four problem pages at once.
What are the command line commands for git?
We use git for source control of our iOS projects. I found a great cheat sheet of git commands here:
Git Cheat Sheet.Prevent Duplicate Content
Thursday, December 9th, 2010 by Force 5Having duplicated content within search engines is a very common problem that is often overlooked. You would think having duplicated content will be good for your search rankings, although that is not the case as it may be not useful to the end-user.
www-vs-non-www (Problem)
Search engines recognize your
www.your-domain.comandyour-domain.comas two separate websites. You may not be penalized by having multiple results although you can improve the efficiency for end-users combing through the search results. In addition, if you have a single convention of your domain usage people linking to your site can improve your link backs.www-vs-non-www (Solution)
Since search engines track these as separate sites you need to pick either your
wwwdomain or thenon-wwwdomain. You still want both versions active although what you want to do is to create a 301 Permanent Redirect to your desired domain. For example,http://discoverforce5.comwill redirect your browser tohttp://www.discoverforce5.com. By performing a 301 Permanent Redirect you are telling search engines not to store/index the redirected content for that page/location.One thing to not forget is that you make sure you allow your website URL paths to be included during the 301 Permanent Redirect process. For example,
http://discoverforce5.com/Media-Hub/will send the end-user tohttp://www.discoverforce5.com/Media-Hub/. As you see it makes sure to send the end-user to their original desired page.ASP.NET Code Example:
In this example we want to use the www domain as the main convention and redirect the non-www domain. The code below you see we grab the current domain and the URL path the request was made. We then check to see if the domain includes the www, if not, we perform the 301 Permanent Redirect.
// get server name/domain string sDomain = Request.Url.Host.ToString().ToLower(); // i.e. discoverforce5.com // get url path string sPath = Request.RawUrl.ToString(); // check if www is in the server name if (!sDomain.Contains("www.")) { // server name does not contain www - proceed with 301 Permanent Redirect Response.RedirectPermanent("http://www." + sDomain + sPath); }
Apache Server Example:
With Apache servers this process is easier with utilizing the
.htaccessfunctionality. Below you will see the Apache server equivalent to the ASP.NET example above.RewriteEngine On RewriteCond %{HTTP_HOST} ^discoverforce5\.com$ [NC] RewriteRule ^(.*)$ http://www.discoverforce5.com/$1 [R=301]Inconsistent Linking
Try to keep internal and external page links to your content consistent. For example, don’t link to
http://www.discoverforce5.com/Services/andhttp://www.discoverforce5.com/Servicesandhttp://www.discoverforce5.com/Services/Default.aspxas all three examples are different.If you are interested in learning about how to submit your site to search engines feel free to read “The little things to not forget about during development [Part: 2]“.
Have any SEO needs or questions? Please give Force 5 a call.