Currently I have a static webpage and I am working on a Rails4 app to replace that page.
Lets say my current website URL is: http://www.foo.com
I have a java app that will look for updates in a specific URL: http://foo.com/updates/1.1/updateDescriptor.xml and download some files in that same directory.
Everytime I want to create a new update for my java app, I will use an FTP client and replace the xml and the other files from that directory.
I want to create a public subdomain:
http://files.foo.com and put there the updates directory.
So, my java apps will look for: http://files.foo.com/updates/1.1/updateDescriptor.xml
The problem is that every java app out there will search in the old URL.
So, how can I redirect it in rails?
I tried:
routes.rb <br/>
get '/updates/*all', to: redirect('http://files.foo.pt/updates/%{all}')
But, the URL is not well encoded:
http://foo.com/updates/1.1/updateDescriptor.xml
turns to:
http://files.foo.com/updates/1.1%2FupdateDescriptor
Which is wrong encoded, and a HTTP 404 results!
Do you guys have any idea that may help me on this?
Thanks,
Nuno
Try this get '/updates/*version/*file.*format', to: redirect('http://files.foo.pt/updates/%{version}/%{file}.%{format}')
Related
I have changed all the URLs of my website. (Domain is the same. For example: http://www.example.com/category/sample ----> http://www.example.com/Category/Sample)
Now it seems to have lots of 404 pages that are effecting my SEO.
What should I do to solve this problem? Any suggestion?
Thank you
You can proceed with changing the Context root for your website. Context roots determine the URL of any web-application.
Click here for a short article for making changes to context-roots.
The process may change based on the Server you are using.
Just create sitemap.xml file. There are many online sites available that will create free sitemap.xml file. Just you have to submit your website url and within few seconds they will generate sitemap.xml file. Download this sitemap.xml file and place it into your root directory. When crawler run through your website it will automatically update your all links and within few days you will see all updated links are present in search resulting page like google search engine.
Note: Also, dont forget to update sitemap.xml file path in robot.txt file.
Does anyone know if Brackets Shell uses any URI except the file://...index.html format? I want to point a web service back to the shell and need to provide a valid URI with the URL. The problem is that I noticed that the URL for the index file uses basic system paths and this can change per system or user configuration.
Any way around this little problem?
Edit:
I am trying to access the Instagram API through brackets shell. In order to gain an access token to the OAuth method they use I need to redirect the user to the Instagram Login page to log in then grant access and then Instagram will redirect them back to me based on the call back or redirect url provided from me. If it was as simple as providing just the URL when the call was made I would be fine however to get a client key (which is also needed to access the api) I need to provide the correct call back URL once the key is made and since the shell seems to have no custom file path it's almost impossible to predict the file path based on each users setup on their own pc's. I hope this made sense :)
I searched the source of the brackets-shell, but couldn’t find the startup path. A quick workaround would be adding a meta-refresh to your index.html which redirects to the corresponding URL of your web service.
For example:
<meta http-equiv="refresh" content="0; url=http://example.com">
If you don’t want to select your index.html each time you start your custom shell, you should place your index.html at
Mac: Brackets.app/Contents/dev/src/index.html or Brackets.app/Contents/www/index.html
Win: dev/src/index.html or www/index.html (these folders must be in the same folder as Brackets.exe)
Linux: dev/src/index.html or www/index.html (these folders must be in the same folder as the Brackets executable)
You can get the current location through javascript using
document.location.href
this will return a string like
"file:///C:/Program%20Files%20(x86)/YourApp/www/index.html"
which you might try sending to Instagram. I'm not sure if they will accept file URI's though.
I've looked around a bit and can't seem to figure out how to link to a static file while using Silex. I've seen some similar questions/answers in regards to Symfony, but they involved YML routing files, which I don't use with Silex.
My Situation
I have some files in a /docs folder. Logged in users can upload new pdf files (so, I don't know ahead of time what all of the filenames will be; they're constantly changing).
My Intent
I need to be able to link to these PDF files, so that a click on a link somewhere will open www.myurl.com/docs/myfile.pdf.
The Problem
Due to the routing system in silex, it treats the url as a route (obviously) and throws a Page Not Found error.
Thanks in advance for any feedback!
You need to configure your web server in a way that it does not forward existing files to the front controller. The web servers section of the silex documentation has examples of such configurations for the most popular web servers.
As for the link itself, just link to the file directly, something along these lines:
{{ filename }}
Basically, this is what my app does:
It sends an AJAX request
The server creates a file
The server sends back the URL of the
file location
The client-side will attempt to
create a dialog to download the file
at that location (probably using a
frame? I haven't got this far yet).
My question is, how do I dynamically route to the files I create so that they are accessible when you browse to them? If I don't add a route for them, then they will get a 404 if they try and access the directory they're in.
The files are currently stored in a folder in public.
Would the best way to deal with this make the folder somehow not require a route, so that it can be browsed to directly, and then have an index page on it so they can't view the full list of files? If so, please let me know how I can accomplish this. And on a side note, if you have an idea of how I can accomplish JS displaying the download dialog let me know.
It's Rails 3 by the way.
Thanks!
For a full private set of files: choose a place for your files outside your public directory, then configure X-SendFile support in your web server and finally use send_file in your rails application.
Am working my way thru Ruby on Rails Tutorial: Learn Rails by Example. I'm in the section entitled Mostly Static Pages.
I get an error after I create an HTML page in the public directory which is called public/hello.html and should appear as in Figure 3.3. My problem is that when I try to create the page and make it appear at localhost:3000/hello.html I don't see the rendered page. Instead, I get an error which says "Routing error No route matches "/ hello.html"
I have not made any changes to the routing; I thought that Rails was supposed to be smart enough to find "hello.html" because it's in the same directory as the "public/index.html" page and the name of the page is "hello.html"?
Can you please explain?
If you're like me and powering through the book, I left the server running from the prior chapter, so it was still loading index.html from the demo_app directory.
You're following an old guide. A newer version
http://ruby.railstutorial.org/chapters/static-pages#sec:green
tells you that you need to modify the routes.rb in the config folder.
I spent about an hour crying about this.
Are you sure you typed this correctly? It looks like you've typed "localhost:3000/[space]hello.html" rather than "localhost:3000/hello.html". Please double check.
Move the file to the Public folder. That did the trick for me.
The hint I used is that Rails serves the Public folder by default. So I figured, if I put it in the Public folder, that ought to work. You'll see it's in line with the index file, so I think that's proof, too.
Review your app directory again and make sure you save the file in (my case) :
C:\Users\Nnamdi\rails_projects\sample_app\public\hello.html
I had the same issue but realized that I did not save it in the right directory
..The solution above should work..cheers