how to create .htaccess for ruby on rails? - ruby-on-rails

does anyone know to create .htaccess on rails? Guide me please. Thanks.
regards

You just create the .htaccess file on your website document root. In apache, that would be the document root of your website (could be something like /var/www/your_website.com, or whatever you specified).

Related

Where is the .well-known folder on Heroku going to be, for a Rails 6 website?

I've created a website using Rails 6 on Heroku. I need to drop a file into /.well-known/ but I've no idea where that might be.
I created a folder with that name in the root of the project and checked it in to git, but it doesn't show up there.
It seems that I should use a route to do this, but I don't have a handle on the syntax to use. I basically need to expose a /.well-known/longhashedstring.txt to a 3rd party service for about a minute.
See above answer from Sharj. Put your .well-known folder in /public for Rails 6 and all is good.

Fixing broken onsite links that are not actually broken

sitemap.xml online generators cannot generate links for my domain (http://www.mm-vet.cz) saying the links on my website are broken (404).
w3.org link checker also thinks that (http://validator.w3.org/checklink?uri=http%3A%2F%2Fwww.mm-vet.cz%2F&hide_type=all&depth=&check=Check)
The best parts is that those nonexistent pages actually exist.
What am I missing?
UPDATE:
This is what my .htaccess looks like
RewriteEngine on
RewriteRule ^([a-z0-9-]+)/?$ /index.php?cat=$1 [L,NC,QSA]
This looks like a configuration issue between WordPress and Apache. WordPress is serving the content for those URLs but Apache sees them as non-existent, thus returning a 404 Not Found error. With WordPress' ability to modify permalinks within the dashboard, I don't see why you would need to rewrite your URLs in an .htaccess file. I would suggest removing what you have in your .htaccess file and configuring the permalinks in the dashboard. This should solve your problem.

Ruby Rails - Cant locate routes.rb to add page to site

I am currently working on a project where the majority if the site structure is already in place. I am trying to add a new section to it but am having difficulty getting links to work.
I replicated what another page had however in tutorials I am seeing reference to a routes.rb file which specifies how links work. The problem is i cannot locate the routes.rb file. Is there anything I am missing or is routes.rb specific to a certain version and I am using a different version. Any help would be much appreciated.
I think your routes file was deleted. You can check git status. You will be find deleted file there. Rollback that change or create new file routes.rb in config/ folder.
If the app is a standard Rails app, you should be able to find routes.rb in the app's config/ folder.
How about just using your editor to do a file search and locate the file?
For Sublime Text, cmd + p for MAC will suffice.

Can a Rails app and a Jekyll blog live together?

I have a Rails app and I want to add a blog feature; my idea is to use Jekyll which is a great blog tool, I just need to figure out if it's possible to use http://my.app.com/blog as a url (knowing that Jekyll will run its own server process with its own url).
Does anybody know of a way to accomplish this? It'd be great to be able to do so. Best regards!
... just need to figure out if it's possible to use http://my.app.com/blog
as a url (knowing that Jekyll will run its own server process with its own url).
While jekyll's web server works, it will be probably easier, simpler and safer to use your rails app's webserver for serving all pages.
The simplest way of doing what you want is hooking a jekyll invocation to your server's git repository, so jekyll's static content is added automatically to your rails app's public/blog/ directory every time there is a push.
Create a symbolink link called public/blog inside your app's public folder. Make it point to the generated _site folder of your jekyll repository.
On the git repository that controls the contents of the jekyll blog, add a post-receive hook that does the following:
#!/bin/sh
rm -rf _site
jekyll
Those are the basic steps. You might have to configure the read permissions properly, ignore the /blog/ link if you are using an SCM (like you should) and automate the link creation if you are using Capistrano or Vlad for deploying.
There are other alternatives, like using a real folder instead of a symbolic link and having jekyll generate stuff directly there, but I feel the one I'm presenting is the cleanest.
Would you be using nginx to reverse-proxy the Rails app? If so, you should be able to just carve out an exception so /blog is served directly by nginx instead of forwarded to Rails.
Check out this gem: https://github.com/zbruhnke/bloggy
And this blog post about it: https://blog.engineyard.com/2012/introducing-bloggy-a-simple-way-to-add-a-jekyll-blog-to-any-rails-application
I had the same problem a few weeks ago. If you really have to use Jekyll, I think the best solution is to use the already mentioned Bloggy gem.
However, I wasn't satisfied with this solution, because you still have to duplicate or synchronize a lot of things like templates, routes, stylesheets, and so on. So I decided to implement my own simple Jekyll-like blog functionality in Rails.
You can find my article describing the implementation here: Create a simple Jekyll-like blog in your Rails 4 app.

Advice request: Serve local folder through rails (or not?)

The task: Serve the files located in a local folder on the server to clients over http/80.
In the end, I plan to emulate the folder on the client but that doesn't concern my question.
So, there is an existing Rails app (rest based/xml) on that server that the clients would use in conjunction with these files.
I don't need any logic to be done on the files either on upload or download so I ask myself:
Do I need to involve my Rails app in serving these files?
Shouldn't the webserver solely handle the link between the local files and the clients?
Would this new Rails Metal or Rack integration be part of the solution? (not familiar with either)
I guess the important thing here is http over port 80.
Thanks for any pointers or advice on the matter,
cheers, Max
I know that with the good time investment I could look all this up for a couple of hours and figure it out but I am very very busy saves me alot of time.
Apache? Just add another <Directory> section to your configuration for the Rails app:
Alias /static-files /path/to/the/static-files
<Directory /path/to/the/static-files>
Order allow, deny
Allow from all
# whatever else you need, Options, AllowOverride, etc.
</Directory>
Put the files in a subdirectory of the "public" directory - as with stylesheets and javascripts
you can use X-Sendfile if you are using Apache or Lighty (see this blog post). Nginx supports X-Accel-Redirect. Both of these approaches will let your web server directly send the file without involving your rails app.

Resources