Rebuild Indexes on SQL Server Standard edition We have SQL Server 2008 R2 Standard on a Windows Server cluster. I want to defrag all indexes on a database. 

What is the best approach to disable all connections and allow the rebuild of indexes? 

I might not be able to shutdown web servers. I doubt single user mode would work as my connection might be kicked out. I also doubt restricted user mode would work as the application logs in as dbo. 

One solution that comes to mind is disabling the SQL Server port but not quite sure. Any suggestions?

Edit: I think of setting the database as single_user\restricted_user and connect via DAC and run the defrag job from the command line. Do you think this would work?
Depending on your version of SQL Server, you can do index rebuilds as an ONLINE operation. This is an Enterprise feature.

Failing that (ie Standard Edition etc), look at re-organizing indexes - these will keep them online. Microsoft best practice says that you should generally not do a rebuild operation unless fragmentation is over 30%. You should always do some form of intelligent rebuilding - i.e check fragmentation and take an appropriate action. I can't recommend Ola Hallengren's maintenance solution enough for dealing with this.

https://ola.hallengren.com/

If you are worried about the blocking effect of index rebuilds, I would recommend this sort of approach.