Fixing broken onsite links that are not actually broken - hyperlink

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.

Related

Display 404 error document for invalid urls from apache without hitting rails application

Is it possible to show 404.html error document for invalid URLs using RewriteRule from Apache before it hits Rails application.
We have routes like /website/stats_for_season/1031475/23 in our application. But for some reason google bot is accessing URLs like /website/stats_for_season/1031475 without last part.
I have added below rule to Apache .conf file, without success.
RewriteRule ^website/stats_for_season/([0-9]+)/$ '' [R=404] [L]

rails in-app redirect from root/apex to www

Because of Heroku's apex domain limitations when using their SSL endpoint, I set up DNSimple's Alias to give me root URL functionality.
Now I've got both the root and the www versions of the site up and running over SSL, but I'd like to redirect it all to www., which heroku suggests doing in the (Rails 3.2) app itself.
These are some suggestions floating around for doing this:
add a before_filter in application_controller.rb
redirect in the routes.rb file
use a gem like this one: https://github.com/jtrupiano/rack-rewrite
So what's the best/recommended way to redirect root URL's to www (incl https) in Rails? Details are appreciated since most examples show how to do it the other way around.

Route Wordpress Blog to Rails Subfolder - Blog Links Not Changed

I currently have a Rails app, my_app.com, and an associated Wordpress blog, blog.my_app.com. They are both running independently on Heroku (i.e. no Apache or Nginx scripting)
I am trying to move the blog into a sub-folder of the Rails app, my_app.com/blog without losing any of the blog's existing SEO 'juice'.
I've implemented the rack-reverse-proxy gem and the blog's homepage dutifully appears at http://my_app.com/blog/ as desired. However, all of the links embedded in the blog still point to the sub-domain rather than the app's blog folder.
How do I configure the blog's links to http://my_app.com/blog/post1 as opposed to blog.my_app.com/post1??
My config.ru file:
require ::File.expand_path('../config/environment', __FILE__)
use Rack::ReverseProxy do
reverse_proxy(/^\/blog(\/.*)$/, 'http://my-blog.herokuapp.com$1', opts = {:preserve_host => true})
end
use Rack::Deflater
run MyBlog::Application
In my routes.rb:
constraints domain: 'blog.my_app.com' do
get '(*path)' => 'application#blog'
end
get "/blog" => redirect("/blog/")
In my ApplicationController:
def blog
redirect_to "http://my_app.com{request.fullpath.gsub('/blog','')}", :status => :moved_permanently
end
My WP .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
It sounds like all you need to do is update the URLs in your WordPress site to use the new scheme. The easiest way to do this would be to perform a search and replace in the database:
Search: blog.my_app.com
Replace: my_app.com/blog
However there is one caveat. WordPress stores a lot of serialized data in the database. Serialized strings have a defined length so just changing the strings without updating the length will cause problems.
I like to use this utility to update links in WordPress. It will perform a search and replace on the database and it will properly update serialized data. Make sure you have a backup of your database in case things go wrong.
If you're talking about links that you manually entered, then mtinsley's answer is correct. However if you're talking about links that are auto-generated by WordPress, then the answer is even easier! You just have to go into the WordPress admin and change the Site URL to http://my_app.com/blog/.
HOWEVER, there is a big caveat with this. You are trying to bring along your "link juice". If blog.my_app.com/some/post doesn't redirect to my_app.com/blog/some/post then you will not keep your link juice.
To fix that, you will want to set up htaccess rules or find a WordPress plugin that automatically creates redirects from blog.my_app.com/some/post to my_app.com/blog/some/post. Also, make sure that blog.my_app.com continues to resolve to your blog site during the transition.
Actually, this is one of the things that annoys me most about Wordpress. It's really not designed to be moved. There are settings and internal links scattered all over the database that are specified absolutely instead of relative to the Wordpress base. This makes it a pain in the ass when you want to do something every professional website should do: set up a staging instance, and move it to the live server only when you have everything set up right.
Fortunately, there's an excellent tool to solve this problem:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
It does a database-wide search and replace that automatically solves the problem with PHP serialized values that arises if you try to do it on your own. You can restrict it to only certain tables, and you can preview the changes it will make before executing them. Whenever you move a Wordpress installation, use this tool to search for the old URL and replace it with the new one.

how to create .htaccess for 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).

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