Can Jekyll serve content based on a URL parameter? - wordpress

I'm migrating a blog from WordPress to GitHub pages. In the logs for my site, I've noticed that there are many requests like this:
GET /wp/?feed=atom
This 301 redirects to the ATOM feed for the site.
I'd planned to use httrack to scrape my site and migrate all the static content. But this presents a problem. Is there any way to replicate the /wp/?foo=bar redirects using Jekyll?

You can use Jekyll redirect_from plugin which is one of the rare plugin that can be used on github pages.
The only problem is that yoursite.github.io/wp/?foo=bar from the server point of view is yoursite.github.io/wp/index.php?foo=bar. So, any ?foo=bar is resolved to the same file.
I you have only your xml feed to redirect, this does the trick :
---
layout: null
redirect_from:
- /wp/
---
content ...
If you have multiple files to redirect, you will have to switch to a javascript solution from a wp/index.html file.

Related

Export WordPress complete URL list for redirects (website migration)

My WordPress website is completely rebuilt with AEM. The WordPress instance will be taken offline and the AEM instance will go online. With the same domain but the url structure will no longer be the same as also the structure of the website will be new.
Problem: This will cause various WordPress URLs to generate a 404 error later.
My goal: I want to export all WordPress URLs as CSV structured and can therefore set up redirects. Structured means as far as its possible:
A separation is made between pages and posts
Public pages only
etc.
Here is the question: What is the best way to export them and that they are also structured? Is there a plugin, just take a sitemap, maybe Google Search Console or directly from the database?
You can try using export-all-urls plugin. Below links will help you export the URLs.
https://wordpress.org/plugins/export-all-urls/
https://www.greengeeks.com/tutorials/article/how-to-export-wordpress-urls-to-text-or-csv-files/
If you have a pattern in the existing URLs, then you might not have to add rewrite rule for each and every URL. Instead use regex to map all URLs following the pattern to AEM URLs.

Mixed Content: The page at 'https://example.com' was loaded over HTTPS, but requested an insecure stylesheet error in Wordpress site

Instead of genuine Mixed Content issue this seemed like more of a Wordpress issue hence posting here to find a resolution.
I have everything setup to work with https, though there is no valid certificate yet. here is the home page url https://tourpoule.nl. The home page loads but with Mixed content errors which seem to be generated by core Wordpress or theme functions. Attaching image:
Database does not have any url which would start with http://. I already have replaced them using search and replace script.
There is nothing in htaccess file except basic Wordpress setup code. I tried renaming it as well. I cleared all types of cache but still it does not work. The site is using twentytwenty theme and if I comment out css and javascript enque lines, some of the errors disappear but styles and scripts do not load(that is normal I know).
In the view source of page it shows mixed urls, some with https and style and javascript urls without https. see below:
Interestingly if I click a stylesheet url i.e. http://new.tourpoules.nl/wp-content/themes/twentytwenty/style.css?ver=1.0 it redirects to https://new.tourpoules.nl/wp-content/themes/twentytwenty/style.css?ver=1.0
I am not sure what is going on and have got struck. I am not able to reach the client so that we can discuss turning ssl redirection off in nginx for this domain where it is redirecting everything to https if it is not https. Not sure if that is causing issue (I believe it is not as it has nothing to do with Wordpress mechanism to generate urls). Any help or direction is greatly appreciated.
I can see your website is still unsecured, for what it's worth, get yourself letsencrypt ssl.
Back to you question, go to your database, open the wp_options table, change the siteurl item to https://tourpoules.nl and also change the home item to https://tourpoules.nl.
If you have used search and replace DB master script or plugin it will not update inside meta files as well as and check for the function file have you Enqueue with https://
So will be better if you download SQL file and replace with below:
From:
http://new.tourpoules.nl
To
https://new.tourpoules.nl
and re-upload again

Theme is not working in Octopress for a custom domain

I've recently migrated my blog from Wordpress to Octopress.
URL of blog is:
myproject.github.io/octopress
Later I added an A-record to DNS settings of my Wordpress site:
myexample.com points to 192.30.252.154
Issue:
After loading Octopress blog from myexample.com in a browser the standard theme doesn't get loaded, whereas from myproject.github.io it does. Other media like text, pics etc. is loaded in both cases.
Any help appreciated!
This due to the fact that you're serving from two different url schemes : myexample.com and username.github.io/octopress. Here the main difference is the /octopress path.
This is supposed to be taken into account in _config.yml :
# If publishing to a subdirectory as in site.com/project set 'root: /project'
root: /
From the yourdomain.com point of view, it's supposed to be / and from username.github.io/octopress point of view, it's supposed to be /octopress.
This what break resources loading in one of the cases.
But the main problem here is the mix between custom domain and github url.
You'de better put your CNAME file in your username.github.io repository, this will make github redirect all request to username.github.io to yourdomain.com. And all request to username.github.io/repository to yourdomain.com/repository.
You will have only one url per repository and no more error possible with the octopress config.
By setting the configuration variable url: http://yoursite.com you will also solve the canonical problem generated by this double url problem. Because of SEO and duplicate content.

Use title based slugs and archive IDs at the same time

A wordpress site I am working on was previously windows hosted and could not use htaccess to hide the index.php. All 200 or so news items are indexed by the search engines like
sitename.com/index.php/archives/5574‎
The site is now being moved to Linux, and the news items will now be like
sitename.com/big-story-of-the-week
If I change the permalink structure as proposed, is there any way I can get the site to still route the old index.php/archive links?
In your .htaccess file, you can add the following code using your sites URL structure:
Redirect 301 index.php/archives/5574‎ http://sitename.com/big-story-of-the-week
This would have to be done for each page.
More info here: http://wp-mix.com/redirect-urls-htaccess/
(Be sure to backup your .htaccess prior to making changes)

Reverse proxy heroku app to wordpress blog

I've managed to setup a reverse proxy of my heroku app with the following in config.ru
require ::File.expand_path('../config/environment', __FILE__)
use Rack::ReverseProxy do
reverse_proxy /^\/blog(.*)$/, 'http://blog.domain.com$1', opts={:preserve_host => true}
end
run Appname::Application
This allows my heroku app to run at domain.com and have domain.com/blog appear as the URL while the wordpress site is being served blog.domain.com. Great so far.
The wordpress site gets served properly when going to domain.com/blog, however when I go to any deeper page like an individual post wordpress throws an error. I was using permalinks with the date and title in the URL of the form: domian.com/blog/2012/07/a-great-blog-post - Worpress now seems to not like this. When I switched the links back to the form domain.com/blog/?p=4 the page gets served successfully.
It seems like it doesn't handle and sort of trailing slashes after the inial domain.com/blog properly. What I find strange is domain.com/blog/wp-admin (and the entire WP admin app) works without any hiccups.
Can anyone see any glaring issues why the pages/post with multiple slashes '/' might be causing problems?
Thanks in advance!
Well I found a solution, for whatever reason in the WP settings for the permalink, it didn't like any of the default options except for the form where it can retrieve the post by id. (http://www.domain.com/blog/?p=123)
For SEO purposes I wanted the title of the post to be in the URL. So I entered in the custom structure field:
/index.php/%postname%/
It seems like it was requiring index.php for wordpress to handle the routing properly.

Resources