How to set up Umbraco to default in a subpage? - redirect

I have this question about umbraco structuring and I can't find the answer anywhere.
Typically in Umbraco it will default the root site to the first node of the tree.
so if we have
Home
page 1
page 2
the default page will be home (so www.mysite.com will point to home).
How do I change this however so that www.mysite.com will point to page1 or page2?
What if I have this structure?
wrapper
index
page 1
page 2
and I want www.mysite.com to go straight to www.mysite.com/index.aspx
I couldn't find a rule that does that. Tried inserting a rewrite/redirect rule and it didn't change anything.
Please help
Nick

Redirecting in Umbraco is usually a very simple affair, except when you're trying to redirect from the root node of your site.
Method 1:
It explains it best here : http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracoredirect
So it's possible by adding a umbracoInternalRedirectId property to your root node, with the data type of Content Picker. Note that it does not redirect the user but instead load the contents of that page inside the current url. So the URL will remain as http://www.mysite.com whilst serving the contents of the page that you want to redirect to.
Method 2:
If you really want it to change from http://www.mysite.com/ to http://www.mysite.com/index.aspx. I usually add something like the following code to the template of the root node.
<%# Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
</asp:Content>
<script type="c#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("http://www.mysite.com/index.aspx");
}
</script>
So that ASP.Net is responsible for the redirect. But it obviously won't handle node rename/moving too well.

you can redirect to any page using Url Rewriting
Config/UrlRewriting.config
adding this Role
<add name="role1"
virtualUrl="^~/$"
destinationUrl="~/home"
redirect="Application"
redirectMode="Permanent"
ignoreCase="true" />

This will do the trick: add a rewrite rule to the Web.Config -
<rewrite>
<rules>
<rule name="Redirect to front" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/yourViewName" />
</rule>
</rules>
</rewrite>
Just include that inbetween the system.webServer tags within the configuration tags, and replace yourViewName by the appropriate view's name (like Contact or Work) and you're done!
All tested & works like a dream.
Cheers #

Related

How to redirect MVC app action calls to distant web api using IIS url rewrite

I have a website (.net core, compiled all in dlls, i.e. no views, no javascript available to modify) which I don't have the source code (was made by someone else who's no longer reachable) and my client wants a single page on this website that makes an ajax call to an action of a controller in this same app to be redirected to a new web api method.
So, for example, this page (_http://the-old-site.com/Home/Index) have a form with a field and a button. Upon entering some values in the form's field and pressing the button, a POST ajax call is made to _http://the-old-site.com/Home/Process passing the value to the action.
I'm trying to configure the url rewrite module so that instead of calling _http://host.com/Home/Process, it posts to _http://new-api-I-did.com/Process
Right now, my rule looks like this but it's never hit:
<system.webServer>
<rewrite>
<rules>
<rule name="redirect to api" stopProcessing="true">
<match url="/Home/Process" />
<action type="Rewrite" url="http://new-api-I-did.com/Process" />
</rule>
</rules>
</rewrite>
</system.webServer>
The api in itself works perfectly when testing it with Postman.
Everything works except for the rewrite. And I tried both rewriting and redirecting.
Thanks in advance.
EDIT
Got the rule working but now, what's being sent in the redirection is an OPTIONS instead of a POST and the form's data aren't sent... Not sure how I can do this anymore.

Seam redirection with condition based on EL

I have a seam web application.
During the user navigation I want to above the user to access again to login page, after successfull login.
When user is log-in successfully it is redirected to home.xhtml page.
If (after login) the user type again the url of login page I want to redirect it automatically to home.
I tried with Seam pages.xml:
<page view-id="/common/jsp/login.xhtml">
<navigation>
<rule if="#{myUserBean.isUserAlreadyAuthenticated()} ">
<redirect view-id="/home.xhtml"/>
</rule>
</navigation>
but it doesnt' work. Probably because Seam manual specify:
Rules work by evaluating the return value of the action method; it is
not possible to evaluate an arbitrary EL expression.
But in my case it doesnt'come from any specific action, the user is asking for login page from an already logged session, where he can have alredy did a lot of actions, or also no one.
Do you have any suggestion?
I should have solved in this way:
<page view-id="/common/jsp/login.xhtml" action ="#{myUserBean.isUserAlreadyAuthenticated()}">
<navigation>
<rule if-outcome="true">
<redirect view-id="/home.xhtml"/>
</rule>
</navigation>

What is the best approach for redirection of old pages in Jekyll and GitHub Pages?

I have blog on github pages - jekyll
What is the best way to solve url strategy migration?
I found the best practice in common is create htaccess like so
Redirect 301 /programovani/2010/04/git-co-to-je-a-co-s-tim/ /2010/04/05/git-co-to-je-a-co-s-tim.html
But it does not seems to work with Github. Another solution i found is create rake task, which will generate redirection pages. But since it's an html, it's not able to send 301 head, so SE crawlers will not recognize it as an redirection.
The best solution is to use both <meta http-equiv="refresh" and <link rel="canonical" href=
It works very well, Google Bot reindexed my entire website under new links without losing positions. Also the users are redirected to the new posts right away.
<meta http-equiv="refresh" content="0; url=http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/">
<link rel="canonical" href="http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/" />
Using <meta http-equiv="refresh" will redirect each visitor to the new post.
As for Google Bot, it treats <link rel="canonical" href= as 301 redirect, the effect is that you get your pages reindexed and that is what you want.
I described whole process how I moved my blog from Wordpress to Octopress here.
http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/#redirect-301-on-github-pages
Have you tried the Jekyll Alias Generator plugin?
You put the alias urls in the YAML front matter of a post:
---
layout: post
title: "My Post With Aliases"
alias: [/first-alias/index.html, /second-alias/index.html]
---
When a user visits one of the alias urls, they are redirected to the main url via a meta tag refresh:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="0;url=/blog/my-post-with-aliases/" />
</head>
</html>
See also this blog post on the subject.
redirect-from plugin
https://github.com/jekyll/jekyll-redirect-from#redirect-to
It is supported by GitHub and makes it easy:
_config.yml
gems:
- jekyll-redirect-from
a.md
---
permalink: /a
redirect_to: 'http://example.com'
---
as explained at: https://help.github.com/articles/redirects-on-github-pages/
Now:
firefox localhost:4000/a
will redirect you to example.com.
The plugin takes over whenever the redirect_to is defined by the page.
Tested on GitHub pages v64.
Note: this version has a serious recently fixed bug which wrongly reuses the default layout for the redirect: https://github.com/jekyll/jekyll-redirect-from/pull/106
Manual layout method
If you don't feel like using https://github.com/jekyll/jekyll-redirect-from it's easy to implement it yourself:
a.md
---
layout: 'redirect'
permalink: /a
redir_to: 'http://example.com'
sitemap: false
---
_layouts/redirect.html based on Redirect from an HTML page :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
{% comment %}
Don't use 'redirect_to' to avoid conflict
with the page redirection plugin: if that is defined
it takes over.
{% endcomment %}
<link rel="canonical" href="{{ page.redir_to }}"/>
<meta http-equiv="refresh" content="0;url={{ page.redir_to }}" />
</head>
<body>
<h1>Redirecting...</h1>
<a href="{{ page.redir_to }}">Click here if you are not redirected.<a>
<script>location='{{ page.redir_to }}'</script>
</body>
</html>
Like this example, the redirect-from plugin does not generate 301s, only meta + JavaScript redirects.
We can verify what is going on with:
curl localhost:4000/a
This solution allows you to use true HTTP redirects via .htaccess — however, nothing involving .htaccess will work on GitHub pages because they do not use Apache.
As of May 2014 GitHub Pages supports redirects, but according to the jekyll-redirect-from Gem documentation they are still based on HTTP-REFRESH (using <meta> tags), which requires full a page load before redirection can occur.
I don't like the <meta> approach so I whipped up a solution for anyone looking to provide real HTTP 301 redirects within an .htaccess file using Apache, which serves a pre-generated Jekyll site:
First, add .htaccess to the include property in _config.yml
include: [.htaccess]
Next, create an .htaccess file and be sure to include YAML front matter. Those dashes are important because now Jekyll will parse the file with Liquid, Jekyll's templating language:
---
---
DirectoryIndex index.html
RewriteEngine On
RewriteBase /
...
Make sure your posts that require redirects have two properties like so:
---
permalink: /my-new-path/
original: blog/my/old/path.php
---
Now in .htaccess, just add a loop:
{% for post in site.categories.post %}
RewriteRule ^{{ post.original }} {{ post.permalink }} [R=301,L]
{% endfor %}
This will dynamically generate .htaccess every time you build the site, and the include in your config file ensures that .htaccess makes it into _site directory.
RewriteRule ^blog/my/old/path.php /my-new-path/ [R=301,L]
From there, it's up to you to serve _site using Apache. I normally clone the full Jekyll repo into a non-webroot directory, then my vhost is a symlink to the _site folder:
ln -s /path/to/my-blog/_site /var/www/vhosts/my-blog.com
Tada! Now Apache can serve the _site folder from your virtual root, complete with .htaccess-powered redirects that use whichever HTTP response code you desire!
You could even get super fancy and use a redirect property within each post's front matter to designate which redirect code to use in your .htaccess loop.
The best option is to avoid url changes altogether by setting the permalink format in _config.yml to match your old blog.
Beyond that, the most complete solution is generating redirect pages, but isn't necessarily worth the effort. I ended up simply making my 404 page a bit friendlier, with javascript to guess the correct new url. It doesn't do anything for search, but actual users can get to the page they were looking for and there's no legacy stuff to support in the rest of the code.
http://tqcblog.com/2012/11/14/custom-404-page-for-a-github-pages-jekyll-blog/
Since github doesn't allow 301 redirects (which isn't surprising), you'll have to make a decision between moving to your new URL structure (and taking a search engine hit) or leaving the URLs the way they are. I suggest you go ahead and make the move. Let the search engine chips fall where they may. If someone hits one of your old links via the search engine, they'll be redirected to the new location. Over time, the search engines will pick up your changes.
Something you can do to help matters is to create a Sitemap where you only list your new pages and not the old ones. This should speed up the replacement of old URLs with the new ones. Additionally, if all your old URLs are in your '/programovani' directory, you can also use a robots.txt file to tell future crawls they should ignore that directory. For example:
User-agent: *
Disallow: /programovani/
It will take a little while for the search engines to catch up with the changes. This isn't really a big deal. As long as the old URLs still exist and redirect actual people to the active pages, you'll be fine.
As others have mentioned, the best solution is to preserve working URLs or duplicate the pages and specify a canonical URL.
Since github pages doesn't support true redirects, I chose to set up rerouter on Heroku to return 301 (permanent) redirects from my site's old domain to the new one. I described the details here:
http://joey.aghion.com/simple-301-redirects/
Jekyll has gone through some major updates in the past few months, so maybe this wasn't possible when this question was originally posted...
Jekyll supports a permalink attribute in the YAML front-matter section of your blog posts. You can specify the URL that you would like your post to have and Jekyll will use that (instead of the filename) when generating your site.
---
title: My special blog post
permalink: /programovani/2010/04/git-co-to-je-a-co-s-tim
---
My blog post markdown content

Atlassian Confluence - Redirect to a new page on 404 Error

confluence-3.2.1_0
How to make a redirect to a new page(create page in current space) on 404 Error in Atlassian Confluence?
I think I need to change action in web.xml:
<error-page>
<error-code>404</error-code>
<location>/fourohfour.action</location>
</error-page>
To something like:
<error-page>
<error-code>404</error-code>
<location>/createpage.action</location>
</error-page>
/pages/createpage-entervariables.action?spaceKey=KEY
but you don't have the key so I think you have a problem
From the steps listed here, instead of updating the 404 page you could update your links so that if the page exists, the user is redirected there, otherwise they are able to create the page.
The links are of the style-
http://xxxxx/pages/createpage.action?spaceKey=experiment&title=this+does+not+exist&linkCreation=true&fromPageId=623770
While my answers a bit different, (no create page, I just redirect to main SPACE), here is it. Very Simple and could possible be tailored for what you want.
Note: 404.vm is what is called by fourohfour.action. Just leave web.xml alone and edit 404.vm!
sudo mv /opt/atlassian/confluence/confluence/404.vm /opt/atlassian/confluence/confluence/404.vm.original
sudo nano /opt/atlassian/confluence/confluence/404.vm
<!DOCTYPE HTML>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1; url=http://example.com/url">
<script>
window.location.href = "http://example.com/url"
</script>
<title>Page Redirection</title>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow the <a href='link'>http://example/url'>link to example</a>

301 Redirects using Typepad

Does any know if it is possible to do redirects using Typepad?
Not domain mapping but pure honest to goodness 301 redirects. There seems to be some mention of a .htaccess file put in the root of the site working but it has not worked for me.
In your header, you can add a meta Refresh tag with time set to zero, pointing to your new blog.
Example:
<meta http-equiv="refresh" content="0;url=http://example.com/" />
If Typepad allows, insert this inside your <head> section. And while you're at it, add a rel=canonical tag pointing to your new domain, too.