A former twenty something in technology

All posts in DotNetNuke

Remove the Useless WWW from DotNetNuke

Categories: DotNetNuke
Comments: No

If you’re like me and find the use of WWW in URLs both unnecessary and annoying then here is a little tip for you to easily remove it from all your urls.

Note: Before you proceed make sure you have an DNS (A) record setup already for your domain with and without the www.

DotNetNuke provides a FriendlyURL Provider that allows for regular expression matches in Host Settings. Here you can create a new rule that removes the WWW and issues a 302 redirect to the non-www domain.

Create a new rule that:

  • Matches: (.*)www.(.*)
  • Replaces: $1$2

RemoveWWW

The DNN EventLog contains a great deal of information. It Includes everything from critical errors to mundane items such as when a user logs in. All of which enables it to fill up very quickly and can be a burden to manage if you have multiple installations of DotNetNuke.

In order to solve this problem I wrote a SQL script that can be run as part of your server’s maintenance plan or ad-hoc. The goal of the script is to find all the DotNetNuke databases on your server and truncate the EventLog table.

How it works:

  • Searches through all your databases.
  • Locates the databases that contain a DotNetNuke application.
  • Finds the EventLog even if an object qualifier has been added to the tables.
  • Truncates the table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
--Application: Clear EventLog in all DotNetNuke Databases
--Created By: Jonathan Sheely
DECLARE @DEBUG BIT
SET @DEBUG=1 --Switch from EXEC to PRINT
DECLARE @dbname NVARCHAR(100)
DECLARE @EventLogTableName NVARCHAR(100)
DECLARE @ParmDefinition NVARCHAR(100)
DECLARE @sqlstr NVARCHAR(MAX)
DECLARE @sqlout NVARCHAR(100)
SET @ParmDefinition = N'@objOut nvarchar(100) output';
DECLARE databases CURSOR FOR
SELECT [name] FROM sys.databases
OPEN databases
FETCH databases INTO @dbname
WHILE (@@FETCH_STATUS<>-1)
BEGIN
SET @sqlstr='USE [' + @dbname + '];
SELECT @objOut=1
FROM sys.tables
WHERE [name] = ''aspnet_Applications'';'
SET @sqlout=NULL
EXEC sp_executeSQL @sqlstr,@ParmDefinition,@objOut[email protected]sqlout OUTPUT
IF @sqlout=1
BEGIN
SET @sqlstr='USE [' + @dbname + '];
SELECT @objOut=loweredApplicationName
FROM aspnet_Applications;'
SET @sqlout=NULL
EXEC sp_executeSQL @sqlstr,@ParmDefinition,
@objOut[email protected]sqlout OUTPUT
IF @sqlout='dotnetnuke'
BEGIN
SET @sqlstr='USE [' + @dbname + '];
SELECT @objOut=[name]
FROM sys.tables
WHERE [name] like ''%EventLog'';'
SET @sqlout=NULL
EXEC sp_executeSQL @sqlstr,@ParmDefinition,
@objOut[email protected]sqlout OUTPUT
IF @sqlout IS NOT null
BEGIN
SET @EventLogTableName[email protected]sqlout
SET @sqlstr = 'USE [' + @dbname + '];
TRUNCATE TABLE ' + @EventLogTableName +';'
IF @DEBUG=0
BEGIN
EXEC sp_executeSQL @sqlstr
END
ELSE
BEGIN
PRINT @sqlstr
END
END
END
END
FETCH databases INTO @dbname
END
CLOSE databases
DEALLOCATE databases
view raw file1.sql This Gist brought to you by GitHub.