This project has moved and is read-only. For the latest updates, please go here.

Rewrite/Redirect Rules

Aug 14, 2013 at 2:49 PM
Edited Aug 14, 2013 at 4:44 PM
I have a bunch of questions regarding how this module is intended to operate and i cant find the answer on the project site, im wasnt sure if i should post them on mass but...

1) "Rewriting of all urls of home page to alias"
I can still type localhost/default.aspx and it will go there and not redirect to localhost/
Is this just because im testing on localhost? or do i need to add a rule for that, if so what would the rule be? i tried few combinations of default.aspx -> / and could get it working.

2) is it possible to redirect non-www urls to www urls with rules, or could it be added as an option or do rules accept wildcards already i.e. URL=domain.co.uk/* -> DEST=www.domain.com/*
Actually, if i add a non-www alias and set the site alias settings to redirect that would do this part wouldnt it?

3) the codeplex homepage for this project says "page not found 404 and redirections 301, 302 detection" how does this work? because for instance i can type in /localhost/random-page-that-doesnt-exist and it will 404, how is thi intended to work?

4) i have a seperate page for terms (different skin) called terms-of-use. creating a rule URL=terms DEST="terms-of-use" and typing terms just goes to terms and shows the dnn default terms page not my page. How is this supposed to work?

5) removing of extensions, i have this set and for urls on the site it works great, but if i browse directly to a page with an extension it doesnt redirect to the same page without an extension. Is this intended, can it be done?
I have managed to create a provider that adds rewrite rules for all tabs that remove the .aspx but im not sure if thats the correct/intended way of doing this? whats your opinion...

FYI: The ui for viewing and adding rules will only show up if you have pop-ups enabled in site settings (DNN 7.03).
Aug 14, 2013 at 11:03 PM
1) "Rewriting of all urls of home page to alias"
I can still type localhost/default.aspx and it will go there and not redirect to localhost/
Is this just because im testing on localhost? or do i need to add a rule for that, if so what would the rule be? i tried few combinations of default.aspx -> / and could get it working.
This is actually not integrated in the rewriter and can not be done with custom url rule. Because this will resolve in a infinite loop because iis add internally default.aspx

For in some situation in can be solved IIS7 and asp.net 4 for exemple. So a will look to integrate this redirection.
2) is it possible to redirect non-www urls to www urls with rules, or could it be added as an option or do rules accept wildcards already i.e. URL=domain.co.uk/* -> DEST=www.domain.com/*
i prefer to add this rule in the dns control panel if possible. But i think it is possible with a custom rule. Its a regular expression.
URL=http://domain.co.uk/(.*) -> DEST=http://www.domain.com/$1
Actually, if i add a non-www alias and set the site alias settings to redirect that would do this part wouldnt it?
I think yes.
3) the codeplex homepage for this project says "page not found 404 and redirections 301, 302 detection" how does this work? because for instance i can type in /localhost/random-page-that-doesnt-exist and it will 404, how is thi intended to work?
If you enable logging, you can see all the 301, 302 and 404 that happens
4) i have a seperate page for terms (different skin) called terms-of-use. creating a rule URL=terms DEST="terms-of-use" and typing terms just goes to terms and shows the dnn default terms page not my page. How is this supposed to work?
Try :
Url = .*/terms
Redirect Destination = http://www.mysite.com/terms-of-use
5) removing of extensions, i have this set and for urls on the site it works great, but if i browse directly to a page with an extension it doesnt redirect to the same page without an extension. Is this intended, can it be done?
yes, this done automatically if the attribute fileExtension in your web.config in set to blank (nothing)
I have managed to create a provider that adds rewrite rules for all tabs that remove the .aspx but im not sure if thats the correct/intended way of doing this? whats your opinion...
No this done automatically if the attribute fileExtension in your web.config in set to blank (nothing)
Aug 15, 2013 at 4:38 PM
2) is it possible to redirect non-www urls to www urls with rules, or could it be added as an option or do rules accept wildcards already i.e. URL=domain.co.uk/* -> DEST=www.domain.com/*
You can do this with a site alias and alias redirection.

Actually only in open url rewriter for dnn < dnn 7.1
But correct this in next open url rewriter version.

Regards,
Sacha
Aug 20, 2013 at 3:16 PM
thanks for all your help i have got msot of what i need up and running now.
i will write extra providers as i need them.
Sep 3, 2013 at 12:15 PM
 2) is it possible to redirect non-www urls to www urls with rules, or could it be added as an option or do rules accept wildcards already i.e. URL=domain.co.uk/* -> DEST=www.domain.com/*
You can do this with a site alias and alias redirection.


I have tried this bit not working for DNN version 7.1. Please help me to solve this issue.

Thanks,

sandeep Gupta

IDSLogic
Sep 3, 2013 at 12:16 PM
sachatrauwaen wrote:
2) is it possible to redirect non-www urls to www urls with rules, or could it be added as an option or do rules accept wildcards already i.e. URL=domain.co.uk/* -> DEST=www.domain.com/*
You can do this with a site alias and alias redirection.

Actually only in open url rewriter for dnn < dnn 7.1
But correct this in next open url rewriter version.

Regards,
Sacha
I have tried this bit not working for DNN version 7.1. Please help me to solve this issue.

Thanks,
sandeep
Sep 4, 2013 at 7:29 AM
Edited Sep 4, 2013 at 7:31 AM
Hi,

It's done for me.

I have 3 urls

xyz.com

xyz.com/en-us

xyz.com/ar-sa


these are not working on www urls.


when I request www.xyz.com then it redirect to default url xyz.com

just I logined with xyz.com/ar-sa in admin panel and in site redirection section , I have added new alias


www.xyz.com

www.xyz.com/en-us

www.xyz.com/ar-sa

and also renamed old urls

xyz1.com

xyz1.com/en-us


You can delete these urls.

and save the setting.


Now u can acess url www.xyz.com/en-us and u found this url is working.


If you have any concern. Please contact me at __email id: sandeepguptamca@gmail.com

Thanks,
Sandeep Gupta

IDS Logic
Sep 4, 2013 at 8:19 AM
Ok, nice.
Sacha
Sep 4, 2013 at 11:48 AM
Hello,
very interesting extension, thanks for sharing!
I just installed it on a DNN 7.1.1 host, and it's working properly except I did not understand how to handle 404 redirects.

I see 404 logged in module's log, but I was not able to build a working rule to handle them.

For example I have an old url like http://www.example.com/amenu/anurl, and I want to redirect it to http://www.example.com/anewurl.

I added a custom rule and tried different filters, but I always get a 404 from IIS and never am redirected as expected:

Url: ./amenu/
Redirect destination: http://www.example.com/anewurl

Url: amenu/*
Redirect destination: http://www.example.com/anewurl

Url: amenu/(.*)
Redirect destination: http://www.example.com/anewurl


How should I write a redirect url in this case?
Thanks for any help,
Alberto.
Sep 4, 2013 at 2:02 PM
Hi,

the syntax is the same as for siteurls.

Example :

Url = .*/hello
Redirect Destination = http://localhost:51924/dnn672-url/en/home.aspx
Redirect Status = 302

Regards,
Sacha
Sep 5, 2013 at 4:06 PM
Sacha,
my fault, I had the old page in recycle bin: after removing it I could get my redirections to work properly - with regular expressions too, this provider is a killer! :-D

I did not check source code, but shouldn't it be possible to filter deleted tabs so to avoid such problems?
Thank you,
Alberto.
Sep 5, 2013 at 4:09 PM
Hi,

I look at this.

Regards,
Sacha
Sep 5, 2013 at 4:10 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.