WordPress and CertBot non-www to www Redirect with .htaccess file

WWW to non-WWW

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443 [OR]
RewriteCond %{HTTP_HOST} !^example.com
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

non-WWW to WWW

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443 [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

In httpd.conf or your-site.conf, you should disable the re-write rule added by CertBot

#RewriteCond %{SERVER_NAME} =www.example.com [OR]
#RewriteCond %{SERVER_NAME} =example.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Read More

Sprint Wi-Fi Calling on iPhone, Google Voice Number Verification and some other issues

On 4/9/2015, Sprint released Wi-Fi Calling feature on iPhone. It is good news for Sprint users because Sprint’s wireless signal is really *BAD*. I enabled it on my iPhone 6 and it was pretty straightforward. You go to “Settings”, select “Phone”, you will see “Wi-Fi Calls” switch. Enabling it will ask you to provide your address for emergency 911 etc. You will need Carrier version Sprint 19.1 and iOS 8.3 to have this option.

Wi-Fi calling doesn’t work at my work’s wifi because the wireless network at my work place has a Captive Portal. When I got home and the phone was connected to my home wifi, the phone shows “Sprint Wi-Fi” on display. Making or receiving calls work perfect. Finally I can make calls using this phone at home.

Trouble began when I traveled to Charlottesville, VA.

#1 Can not make or receive calls in certain area

  • When I tried to call someone using AT&T wireless service, I got “The number you dialed is incorrect, disconnected or no longer in service”.
  • I tried to use my personal phone (AT&T) to call this Sprint phone, the Sprint phone never rings (I forgot if there is any message).
  • I was able to call Sprint’s tech support using this phone although the call was dropped due to bad signal. (Shame on you, Sprint!)
  • I called Sprint support, the tech asked me to do some simple testing and told me they would have to open a ticket, which (of course) was never resolved.
  • I tried to toggle off WiFi calling on my iPhone and it didn’t help either.
  • The second day, I went back home from Charlottesville. the phone works with or without WiFi calling toggled on. Sprint calls me back and told me they were not able to find any issues with my line or my device. When I told them it is working in my home area, the guy was happy to help me close the ticket and told me “You can call us again if you are in Charlottesville area and have the same issue”. lol, nice work!

Trouble #2 can’t pass verification of Google Voice

I tried to add this Sprint number to my Google Voice’s forwarding phones. To do this, Google will call me and ask me to type in a two digit verification code. Guess what, it doesn’t work. I received the call but when I input the two digit verification code, Google side can’t get what I typed in. “I am sorry I didn’t catch that”. Although I have already lost confidence on Sprint Tech Support, I contacted them again just in case they have a knowledge base for Google Voice/Sprint, no surprise. They called me back after 48 hours and told me I have to contact Google for support because “the phone works when call Sprint and is able to touch tone dial Sprint’s service menu”.

So I did the following tests and created a post on Google Voice support forum:

  • unconditional forwarding calls from Sprint number to a land line number. Picked up the call using the land line phone, still not working: same symptom.
  • unconditional forwarding calls from Sprint number to a AT&T number, not working, same symptom.
  • set up AT&T number as a forwarding option in Google voice, works right away.
  • Remove AT&T number from Google Voice, forward all calls from AT&T number to Sprint Number, try to add AT&T number back to Google Voice forwarding numbers. Not working: Same “I am sorry, I didn’t catch that”.
  • I am ABLE to use my sprint phone to access Google Voice’s Voice Mail menu. I was even able to add Sprint number as a temporary forwarding number this way.
  • Toggle off “Wi-Fi calls”. didn’t help.
  • Call (804) 222-1111 to test DTMF. The system was able to tell my input correctly.
  • I also tried this:
    1. Remove my AT&T number from my google voice account.
    2. Forwarding calls from my AT&T number to Sprint number.
    3. re-add AT&T number to Google Voice account and verify.
    4. Use Sprint phone to pick up the call and verify….
    5. Works perfectly.
  • Also
    1. Used Sprint phone to call my GV number and set it up as temp forwarding number.
    2. Removed my AT&T number from GV account.
    3. Use AT&T number to call my GV.
    4. Pick up my sprint phone when it starts to ring.
    5. “Press 1 to Accept the call”. I press 1 but it is not working. Just like the verification call. The other side doesn’t recognize my input.

So after the last test, I finally realized this is not tied to Google Voice’s verification call. It looks like DTMF doesn’t work for inbound calls, but outbound calls are fine. I googled around and found a page saying Wi-Fi calling is a feature on the line to enable/remove beside on the phone (sorry I forgot the url).

I called Sprint to ask removing this feature from my phone. Thank you Sprint, they told me I couldn’t because I am not the owner of this account (Sprint number is a business phone from work) so I can’t remove this feature. I said I enabled it myself and now I can’t remove it? “No, you can’t, unless you have the PIN for this account”. (Sprint, I am surprised you are still in business). I asked to talk to her supervisor, her supervisor has better attitude and told me he would reach out to this account’s dedicated business support staff. After 36 hours, I got a call from Sprint, told me that I could remove the feature from my line on the phone! (so you can disable Wi-Fi calls on the line by yourself)

1. Make sure WiFi calling is toggled on.
2. Click “Update Emergency Contact Address”.
3. It will load a web page and Select “Disable Wi-fi calling feature”

I asked him that I read from some web pages, I will have to update my phone’s profile to complete by dialing a number. he said he was not aware of anything like that and suggested me to reboot my iPhone.

Actually, here is the number “##873283#” (##UPDATE#), this will prompt you “Starting Service Update”, Click OK. The phone will get the latest update from the tower.

All of that being done, I re-login to my Google Voice account, click verify my phone again. Phone rings, pick up, type the two digits number. “Your number has been verified”, in one single try.

I believe Sprint routes inbound call differently for Wi-Fi calls enabled iPhone. That causes trouble for the touch tone not recognized by Google Voice.

Lessons learned:

1. Don’t rely on Sprint’s network and tech support. Their network qualify and tech support’s knowledge are on the same level.

2. I should have dug more into “Update Emergency Address”, but who can imagine Sprint put the real “disable wi-fi calling” here?

3. I will never ever buy Sprint’s service for my personal use. I am lucky this Sprint phone is for my work.


Sprint should be bought by Verizon and the name “Sprint” should become history.







Read More

Custom AccessDenied.aspx Access Denied Page for SharePoint 2010

First you will need to make a copy of the default layout page AccessDenied.aspx which is located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS

For example, you can call it AccessDeniedNew.aspx. This new page layout should stay in “LAYOUTS” folder.

Login to your server as a farm administrator. Start SharePoint 2010 Management Shell. Run the following code:

$site = get-spsite "http://YOUR_SITE_URL"
$webApp = $site.WebApplication
$webapp.UpdateMappedPage(1, "/_layouts/AccessDeniedNew.aspx")

To switch back to the default page, you can use the following code

$site = get-spsite "http://YOUR_SITE_URL"
$webApp = $site.WebApplication
$webapp.UpdateMappedPage(1, $null)

You can get more information about the custom page from Yaroslav’s blog

In the method of $webapp.UpdateMappedPage, 1 is for Access Denied Page. See the following table for other type of pages

AccessDenied = 1

Confirmation = 2

Error = 3

Login = 4

RequestAccess = 5

Signout = 6

WebDeleted = 7

You can use Set-SPCustomLayoutsPage and Get-SPCustomLayoutsPage to reach the same goal as well.


Read More

This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

I got this error when I use Visual Studio 2010 to program some SharePoint 2010 stuff. It is a simple console program. This exception happens at the following line:

SPWebApplication webApplication = SPWebApplication.Lookup(new Uri("http://mysiteurl"));

Below is another error:

The Web application at http://mysiteurl could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

and this happens at line

SPSite site = new SPSite("http://mysiteurl");

Both of the errors have the same root cause.


Right Click your project, Choose Properties. Go to tab “Build”, Change Platform Target from “x86” to “Any CPU”. Recompile your project and you will be all set to go.

Read More

Get-SPSiteAdministration .DiskUsed return nothing

In the article of moving site collection from one content database to another content database on TechNet, There is a PowerShell script which tells how much space used by the site collection:

$used = (Get-SPSiteAdministration -Identity <http://ServerName/Sites/SiteName>).DiskUsed


If you run this on your SharePoint 2010 Management Shell, you will get nothing displayed when you try to show the value of $used.

You will need to run the following code first before you run the above 2 lines of code

Start-SPAssignment -Global

This is a tip from Microsoft SharePoint forum.

You can also use

$storage = (Get-SPSite http://siteUrl).Usage.Storage

this is will get a much larger value than the previous command. I think the reason is that in the previous command: “The amount of disk space that is displayed does not include the disk space used by the auditing data that will be moved with the site collection.”

Read More

SharePoint 2010: Using PowerShell to create Web Application Pool

You can use the following PowerShell code to create a new Application Pool for your SharePoint site

$svc = [Microsoft.SharePoint.Administration.SpWebService]::ContentService
$pool = New-Object Microsoft.SharePoint.Administration.SPApplicationPool "SharePoint App Pool", $svc
$pool.CurrentIdentityType = "SpecificUser"
$acct = Get-SPmanagedAccount DOMAIN\USER
$processAcct = [Microsoft.SharePoint.Administration.SPProcessAccount]::LookupManagedAccount($acct.Sid)
$pool.ProcessAccount = $processAcct

The application pool will be created.

You can update an existing application’s application pool followed by this script:

$webApp = Get-SPWebApplication http://web
$webApp.ApplicationPool = $pool


You can also switch a web application’s application pool to another by using the following PowerShell Script

$sourceWebAppPool = (Get-SPWebApplication http://web1).ApplicationPool
$webApp = Get-SPWebApplication http://web2
$webApp.ApplicationPool = $sourceWebAppPool

Read More

How to make document library web part in top level visible to subsites

here is a solution from Anton Khritonekov @stackoverflow.com:

“There are another option without such hard coding. You can open any view of your document library, as mentioned earlier AllItems.aspx for example with SharePoint Designer. Open it for editing in advanced mode (there are option when you click right mouse button on file in SP Designer). Then just point mouse cursor inside web part and chose in ribbon web parts, Add to Site gallery, see the picture. Fill in name of new web part. That is all, now you can add this web part on any page on any web site from webpart gallery through the user interface or through the SP Designer by clicking Insert, Web Part in the ribbon on any page.”

Read More