Wordpress conditional redirect - wordpress

I have a wordpress website, where I am trying to redirect users to a different page based on a URL parameter. This is what I am trying to solve:-
Current page: - www.mysite.com/hi/
If there is a parameter 'report=show', then I would want the user to be directly redirected to a different page:-
www.mysite.com/hi/?report=show should redirect the user to
www.mysite.com/report If the parameter does not exist, the user should be shown www.mysite.com/hi/
I tried doing a htacess rewrite, but it didn't make any difference.. don't know why!

Not sure why the .htaccess isn't working (as you didn't post it).
Easiest way though is to use the Wordpress Redirection Plugin.
You would add a new redirect rule. Keep the defaults for the other settings, and enter the following two values:
Source URL: /hi/?report=shows
Target Url: /report

Related

Unknown URLs are redirecting to homepage (from www.example.com/page/2345343 to www.example.com)

I'm using a WordPress website and I got this issue, I'm not sure it's an issue or feature in WordPress.
When I enter my website name like www.example.com/page/1234234 (random number) or www.example.com/page, it is redirecting to the home page (www.example.com).
And also when I enter pagination in URLs like www.example.com/blog/page2 and it is redirecting to www.example.com/blog/page/2.
Can anyone explain this?
Its a default wordpress functionality, if you want to change it, you can use filters to change default wp urls

Redirect 301 wp url based on year/month/day to post-name.html

I recently changed the permalink structure from
https://www.domainName.ro/2018/04/10/post-name.html
to
https://www.domainName.ro/post-name.html,
using:
"RedirectMatch rule 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+).html$ https://www.domainName.ro/$4.html" and works.
Now I want to redirect, within the same site (old URL), the URLs from
https://www.domainName.ro/2018/04/10/post-name/
to
https://www.domainName.ro/post-name.html
I tried different rules and did not work.
The two rules must work at the same time on the site
Can you help me?
Thank you very much!
You can manually change the url using wordpress plugin called redirection after install the plugin you can simply add url which you need to redirect from old to new just simple go to tools and there you find redirection click on that and you will find 2 box in 1box you need to enter old url which you need to redirect and 2box you need to enter new url where you need to redirect and click on save and you are done redirecting
Hope this will work for you

Redirects to the page even if url is wrong

Hello I have a problem that in my opinion is linked to permalinks, but I'm not quite sure.
The problem is that my site does only care about the last part of the argument in the url.
For example https://apriori.photo/kontakty/price does not exist. But it 301 redirects to https://apriori.photo/arenda-fotostudii/price/
I tried deactivating all the plugins and setting a default wordpress theme, the problem stays.
My permalink structure is : /%category%/%postname%/
WordPress has a feature where it automatically tries to redirect to a page which it deems to be 'the correct page' based on it's name. In your case, because the page ends with 'price', WP finds another page with a similar path and thinks it should redirect there.
To prevent this, you can disable the redirect using the following:
// In functions.php
remove_action('template_redirect', 'redirect_canonical');

Drupal URLs migrated to new WordPress installation

We have an existing Drupal site. That is going to be replaced with a WordPress site on the existing URL. However, there has been a lot of SEO done on the drupal URLs so a google search will return those old URL's. We want to redirect to the new corresponding URL in the Wordpress site. However, since the drupal site is no longer live on the existing domain, the old URL's will just return 404 and cannot be redirected since they are not relative to the WordPress root. Is there a way to do this? Do I need to get those old drupal site URLs into WordPress somehow?
First of all you need to update your sitemap and add canonical's for permanent redirections. This wont directly redirect the page, but will let the search engines know that the url for the page has been changed and hence will avoid loosing your search engine rankings.
Then for actually redirecting the page you will need to update your htaccess
Redirect 301 /folder/oldpage http://www.example.org/newpage
If there are lots of pages you should consider using a wordpress plugin called redirection. This way you dont have to update the htaccess manually, and it will also keep logs of all the 404 pages that users have found, so you can also keep an eye on logs for any missing pages and redirect them accordingly.

Changing WordPress URL structure - Redirects

I'm changing my URL structure from domain.com/postname to domain.com/type/postname
What's the best way to redirect? I tried using the Redirection plugin, but it seems that I need to redirect each URL manually. Is there any way to redirect all the posts at once?
Go to the wp-admin's dashboard using domain.com/wp-admin. Then look for the Settings-->Permalinks option. From this page you can change the URL settings for all of your posts.
Here are some instructions on how to redirect your sites url.
Changing the site url
Back up your site first if you still can? When I changed to pretty permalinks I had to include a forward slash to custom field images.
from: wp-content/uploads/2012/08/tulip-813-01.jpg
to: /wp-content/uploads/2012/08/tulip-813-01.jpg

Resources