Changing the URL for doc files

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
10/20/2011 11:15:15 AM
Gravatar
Total Posts 23

Changing the URL for doc files

On our current website, the URL to get to documents (pdf, doc, etc) is something like:

www.mysite.com/documents/file.pdf

We are currently building up our new mojo site, and the URL is something like:

www.mysite.com/Data/Sites/1/documents/file.pdf

 

What can I do to make the original URL work in mojo? I found someone asking the same question here:

http://www.mojoportal.com/Forums/Thread.aspx?pageid=5&mid=34&ItemID=5&thread=7756&postid=31932

but no responses...

 

Thanks for the help in advance!

10/20/2011 11:51:19 AM
Gravatar
Total Posts 18439

Re: Changing the URL for doc files

You can't really change where mojoPortal stores the files, but if you want the old url to work in addition to the new one, you could create a virtual directory named "documents" below the root of your site and point it to the physical folder at /Data/Sites/1/documents/

Hope that helps,

Joe

11/8/2011 10:40:26 AM
Gravatar
Total Posts 23

Re: Changing the URL for doc files

Hi Joe,

I just wanted to follow up - this solution worked great for us. Thanks for the help.

 

However, we have a related issue. Our webmaster saved quite a few documents in the root folder of the old site, so they would come up as:

www.oursite.com/document.pdf

Again, they want our new Mojo site to be able to mimic this behavior.

 

I don't think a virtual folder will work here, because it is the root directory. I think individual file redirects would work - yes? Is this a good idea? Any better suggestions?

 

Thanks again for your help.

11/8/2011 11:10:37 AM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Changing the URL for doc files

If it's a question of SEO in maintaining that root position, what I would personally do is move the "root" documents to the new documents directory, and in IIS put in 301 redirects for each of those files that have moved. That way you have a roadmap toward consistency and don't have to maintain legacy file locations. Going forward the webmaster should use /documents exclusively.

Since it sounds like you're in the preliminary planning stages of your implementation, I'll give you another tip that would have helped us out when we were at that stage. Rather than using:

www.mysite.com/Data/Sites/1/documents/file.pdf

You may want to consider using:

www.mysite.com/Data/Sites/1/media/documents/file.pdf

The reason for this is that non-Admin users who are given access to upload files in the editors will be shown the file tree starting from Data/sites/[site]/media, so they wouldn't be able to see/replace files located in Data/sites/[site]/documents.

Because of this, we've recently been going through a major reconfiguration of our files to move everything under the media folders so we can begin decentralizing maintenance of our sites. Once we're finished with this reconfiguration, we will turn on the "ForceAdminsToUseMediaFolder" key in user.config so file access through the sites will be consistent for all site editors.

If I could go back in time, I would have turned on that key from the very start! cool

I hope that helps,
Jamie

11/21/2011 2:44:15 PM
Gravatar
Total Posts 23

Re: Changing the URL for doc files

Thanks for the tip-

So I started trying to do 301 redirects using the 301 redirect manager in mojo, and it does not seem to be working. For example,

www.mysite.com/file.wmv

redirects to:

www.mysite.com/Data/Sites/1/documents/file.wmv

 

BUT...

the redirect doesn't work, and when I try the original URL, I still get a page not found error. I tried clicking on the target page, and it works, so that isn't the problem. Is there something I need to configure for the 301 manager to handle different file extensions?

11/21/2011 4:06:29 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Changing the URL for doc files

I think you should do these redirects at the IIS level. I believe the mojoPortal 301 redirect manager is only meant to work with renamed mojoPortal pages.

11/22/2011 10:34:23 AM
Gravatar
Total Posts 23

Re: Changing the URL for doc files

OK, problem is I know nothing of IIS. The couple developers can help some, but none are familiar with 301 redirects. I googled it, and came back with ways that look like they would redirect entire sites, like this:

http://www.mcanerin.com/en/articles/301-redirect-iis.asp

 

I don't understand how I can apply this to specific cases without messing with the rest of the site.

The other one is that this only seems to redirect from something that exists (old page, old folder, etc). I am making this assumption, because it seems you only enter the target for the redirect, not the source. I am guessing this means that the source is whatever you are working with in IIS. My problem is that I am working backwards. I have targets, and I want to be able to enter sources to point to them. Does this make sense?

Let me try to say it a different way. I want to take a url that no longer works, because it doesn't point to anything anymore, and redirect it to something that DOES exist.

Basically, we have some broken links (pages and documents) that used to work, but do not anymore, and one of the execs is insistent that we make these work again. In some cases, with pages, I can probably just do it by creating pages and typing in new URLs, although I'm not even sure about that. Anyway, I don't think I can do this with specific doc files at all, so I need another method. It sounds like the 301 redirect thing might work, but I don't know what to do.

 

Thank you so much for your help!

 

11/22/2011 11:18:34 AM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Changing the URL for doc files

It took me awhile to figure out how to do redirects in IIS too. The easiest way to do it is through IIS Manager. In IIS Manager, drill down into your site in the left pane. Here, you can select a directory and then in the right pane select HTTP Redirect and make it point to where you want with a Status code of Permanent (301). This is how you should set up your /documents directory redirect.

It's a little more complicated to interactively set up redirects for individual files. When you browse to the location that holds your files to be redirected, in the left pane right-click on the folder with your files in it, and select Switch to Content View. In the right pane you'll see the contents of the folder. In the right pane, find a file to be redirected, and right-click on it, then select Switch to Features View. At the top of the right pane you'll see the file's name and icon displayed, indicating that you are operating on that file. Now you can select HTTP Redirect, and it will set up a redirect just for that selected file.

Behind the scenes, what this process does is to create redirect entries in a web.config file that look like this:

<location path="MyFile.pdf">
        <system.webServer>
            <httpRedirect enabled="true" destination="http://www.mysite.com/Data/sites/1/media/MyFile.pdf" httpResponseStatus="Permanent" />
        </system.webServer>
    </location>

For folders and files that are outside of the mojoPortal root (like your /documents directory), this is not an issue since it will creat a new standalone web.config file. However, I think your root documents may actually be sitting in the root of your mojoPortal site. If this is the case, the redirect entries will be added to the big web.config file for your site. This is not a problem per se, but you'll just need to be aware that these entries are customizations, and they will have to be manually migrated to the newly delivered web.config file each time you upgrade mojoPortal.

I hope that helps.
Jamie
 

11/22/2011 11:41:20 AM
Gravatar
Total Posts 18439

Re: Changing the URL for doc files

If you install the IIS Url Rewriting module you can use it to do pattern based redirects which would probably be much less tedious if you have a lot of files that need redirecting.

Hope that helps,

Joe

11/22/2011 1:24:52 PM
Gravatar
Total Posts 23

Re: Changing the URL for doc files

Thanks for explaining a little more, but I still think I am going to have a problem. I don't have any of the files in the root directory of Mojo. I only have them in my new documents folder (which I consider the target). For example:

www.mysite.com/Data/Sites/1/documents/file.wmv

It seems to me that this is what I would type in for the redirect. However, I don't know how to get that far, because there are no files to start with.

Now, as I was trying stuff out, here's something I found:

If I move files from the documents folder to the root folder, then the original link:

www.mysite.com/document.pdf

will work. If my goal is to get links working, then this seems to be all that needs to be done. However, I have the feeling this is a bad idea (if for no other reason than it will make the root kind of cluttered). What else should I be worried about?

11/22/2011 2:39:30 PM
Gravatar
Total Posts 18439

Re: Changing the URL for doc files

If the redirect is working correctly the files don't need to exist in the old location.

ie if you are doing a 301 redirect from:

www.mysite.com/document.pdf

to

www.mysite.com/Data/Sites/1/documents/document.pdf

then if the redirect is actually working the file does not need to exist at

www.mysite.com/document.pdf

So the question is only whether you can get the redirect working or not.

Using the IIS Url Rewrite module you should be able to do it. 

Or if you're trying the way Jamie showed you with web.config you may also need to have this attribute on the modules element

<modules runAllManagedModulesForAllRequests="true">

in the system.webserver section

Hope that helps,

Joe

 

You must sign in to post in the forums. This thread is closed to new posts.