Rewrite URLs for DNN - asp.net

I have a site and already trying to do a little url rewritting but want to know if there is a solution to make it better
my current state urls look like this
http://snit.us/Home/tabid/314/CN/1/RE/23/United_States_Missouri.aspx
I want to change them to something more ordered so in my new scheme i want to do this
http://snit.us/Home/United_States/Missouri/default.aspx
obviously the point is that if i remove missouri from the new url it would find all United_States - etc etc etc
even better would be to have http://snit.us/Home/United_States/Missouri so its even less cluttered

I think your best bet would be to implement the free iFinity URL Rewriter for DotNetNuke. At the very least, you should be able to achieve the following:
http://snit.us/Home/CN/1/RE/23/United_States_Missouri
If you're using IIS 6, you'll want to enable extensionless URLs in IIS. If you're using IIS 7, you should not need to make any changes.
To set it up, you'll just need to add the DLL that iFinity provides to your site's bin directory and then follow the instructions that came with the download for configuring your web.config (make sure to make a backup copy of your web.config for safety and convenience).
Here is an example configuration that we use on dnnGallery.net:
<add name="Ifinity.FriendlyUrl" type="iFinity.DNN.Modules.FriendlyUrl.DNNFriendlyUrlProvider, iFinity.FriendlyUrlProvider" includePageName="true" regexMatch="[^\+a-zA-Z0-9 _-]" urlFormat="HumanFriendly" redirectUnfriendly="true" doNotRewriteRegex="(\.axd)|(/DesktopModules/)" doNotRedirect="SearchResults;" doNotRedirectRegex="[.]*(/logoff.aspx)" pageExtensionUsage="never" parameterHandling="ordered" checkForDupUrls="true" forceLowerCase="true" redirectWrongCase="false" replaceSpaceWith="_" redirectDefaultPath="true" />

Related

Load Drupal Site on Any URL

I'm setting up access to a Drupal 7 site. The site sits alone on a box that answers to a number of domains and that number is likely to grow. What I'd like to do is to tell Drupal to load the site regardless of which actual domain brought us to the box (the rest of the URL will always be the same, of course). Currently most of those domains send me to the install page.
The problem is the lack of a directory (symlink) in the sites/ directory.
I can probably rewrite requests coming through alternate domains in Nginx, but I'm wondering whether there's an application level answer. As it stands right now, accessing the box/site by any domain other than the canonical domain sends me to the install page.
Is there anything I can do?
It looks to me that you didn't configure your Drupal site as the "default" one.
The file "sites/default/settings.php" is loaded if no better (more specific to the current request) settings file can be found in the sites/folder... This is in fact a "wildcard" config, so the best solution would be to move the site files to the default folder. See the multi-site documentation for more details.
If you can't do that, then you can use sites.php for the rewriting, but you will need to update it to add any new URL you want to match. There's a little shortcut though: you can add a bunch of rewrites such as
$sites['com'] = 'default';
$sites['net'] = 'default';
$sites['org'] = 'default';
...
which will act as catch-all rewrites for sites ending in .com, .net, .org and so on, saving you a lot of (but not all) the manual rewrites.
Altering the conf_path() function should really be your last solution, since it will make updating Drupal a slower process (and if you forget to re-apply the changes after an update, your setup won't work any more).

subdomain rewriting in ASP.NET?

How do i do this in .NET? http://why.does.my.head.asplode.net/ I want to do something like ytmnd where each url is a different user generated page. I might need something as simple as pointing to a directory so dirname.mysite.com will redirect to http_public/userGenContent/dirname/
I suggest you use UrlRewritingNet. You may have to add a rule similar to this:
<add virtualUrl="http://(.*).asplode.net/index.aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/Users.aspx?username=$1"
ignoreCase="true" />
I cannot test this since I'm on a Linux machine right now, but it should work ;).
HAHA ...
I handled the Begin request event in global.aspx for this because my urls come from sql server.
Why are so many people sub domain crazy these days?
in Begin Request you can do something like this (not usre exactly because I aint got it in front of me right now) ...
request.rewriteurl( "new url" );
... this will take whatever the source url is and "redirect" without a redirect the response to a url you can use internally.
The various UrlRewriting tools will help you once you have the request getting into ASP.NET, however before that happens you need to setup IIS to pass these requests to your app. This is simple enough if there's only one app on the server, but more difficult otherwise.
Check out http://msmvps.com/blogs/bernard/archive/2005/03/22/39218.aspx for some details on wildcard subdomains on IIS.
Alternatively use an IIS level rewriter like ISAPI Rewrite
Essentially search for IIS wildcard subdomain to find a wealth of approaches.
Well, IIS7 has built url rewrite functionality. You can specify rules etc in web.config. But for IIS6 you need ISAPI dll that does the same for you. I've used IIRF and it works just fine.

Change a website's directory names per installation

Is there a way that I can have different directory names per installation of a website? As in I would need to rename the directories at build time or some similar solution. I am currently using MSBuild with CruiseControl.NET.
An example would be I have a module in my website called Bug Tracking which is then in http://mysite.com/BugTracking/.
One installation wants to leave it as BugTracking and another would like to call it "Issue Tracking" for whatever reason and have it in http://theirsite.com/IssueTracking/.
Re-writer rules
You could set up a re-writer rules so you could leave the directory name the same, and just add a re-writer rule for the clients that want it call something different?
IIS7
also look at Scott's blog
Doesn't solve the problem, kind of hides it I know. but its easy :)
or
ASP.NET Routing:
Also worth looking at would be ASP.NET Routing,
Using ASP.NET Routing Without ASP.NET MVC
or
Using Routing With WebForms

Best DotNetNuke url rewriting approach?

I would like to implement a URL rewrriter for DotNetNuke. Have questions as to whether this is a good or possible approach and any suggestions other developers may have.
Can I add a dynamic or static route for URL rewriter from the 'Pages'-> 'Add Page' section?
Let's say I'm creating a page called 'Events' underneath the 'Activities' menu item.
Can I write some custom code in DotNetNuke that will add a prompt on the add page screen that assumes I will want a static or dynamic route added for - site.com/Activities/Events Or if I name the page 'Event Calendar' then it would suggest 'site.com/Activities/Event-Calendar'?
I would like any feedback or suggestions on how I would accomplish this! Thank you.
If you're using DotNetNuke 4.8 or greater, you just need to enable Human Friendly Urls through the Web.Config.
To enable human friendly urls, replace:
<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" />
with:
<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" urlFormat="HumanFriendly" />
UPDATE:
For DNN 7.x and greater, this should now be:
<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9 _-]" urlFormat="advanced" />
Additional Detail: Enable Human Friendly Urls in DotNetNuke
Check this out - details here:
http://www.ifinity.com.au/Blog/Technical_Blog/EntryId/19/Rewriting-the-DotNetNuke-Url-Rewriter-Module/
Also, take a look at the existing FriendlyUrl module that's already included in DNN.
If you want to do this on the stock pages, you'll need to crack open the source for it, or write a module that does this independently.
To answer your question directly : yes, you can add some code to the DNN Page Settings page. However, you'll be modifying the core code and thus won't be able to easily upgrade your installation when the next DNN release is made.
A lot of people come to DNN and want to write a new Url Rewriter. The problem is not the rewriting : it's getting the DNN framework to generate the correct urls where you would like them - in the menus, in generated links within modules. To really change the rewriting scheme you need to replace/augment the Url Rewriting function, the friendly url generation function, and provide some sort of redirect capability in order to tie old and new Urls together.
Another suggestion is Page Blaster, if you are not wishing write your own code. Works well for the sites l use it on.
Several of these are great replies... One of the most important things to know if you are just learning about DNN now (2016 and above) is that the realm of URL Rewriting has changed over time within DNN.
Before, in DNN 4.8 and below you had to use an external module/provider such as:
PageBlaster or
DNN Masters SEO URL REWriter or
iFinity URL REWriter
all of those are mentioned in some of the answers above.
However, after DNN 4.9, iFinity URL ReWriter was incorporated into the DNN core and you'll find it available in DNN 5, 6, 7,and 8 in different levels of exposure to the interface. You still need to do some updates in the web.config, but much of it is done directly within the Page Settings now.
Any settings that are not within the main managers, you can do either in the web.config, or in the database, or you can look for a DNN module such as X3 DNN URL Management which taps into the database records of the integrated DNN url rewriter and helps manage settings (it is very similar to the old iFinity interface screens/options) but you don't need it, you can work directly, it's just helpful.

ASP.NET Web Dev: Map one directory to another?

We are thinking of renaming our web directory schema to be more user friendly. However, we need any URL requests for the old directory structure to forward to the new one. so....
How do I forward requests for all of these:
http://mydomain.com/OLDdirname/
http://mydomain.com/OLDdirname/samesubdir/
http://mydomain.com/OLDdirname/samesubdir/samescript.aspx
to each of these respectively:
http://mydomain.com/NEWdirname/
http://mydomain.com/NEWdirname/samesubdir/
http://mydomain.com/NEWdirname/samesubdir/samescript.aspx
Any suggestions and perhaps some general guidance as far as gotchas?
You can use a number of things to do something like this. Basically, you're doing URL Rewriting. One of these products should help you get the job done:
ISAPI Rewrite
IIS Rewrite
opURL
IIRF
I use IIRF on many of my websites, and it has always worked without failing. You use regular expressions to define the rules, and it takes care of the rest. It would be extremely easy to setup a few redirects using IIRF.
http://cheeso.members.winisp.net/IIRF.aspx

Resources