Wordpress. Rewrite url when on custom taxonomy - wordpress

It's a wordpress site. I am using a plugin called media tags. This plugin create a custom taxonomy called 'media tags' to display media that has been tagged. The url for these pages are currently domain/blog/media-tags/results
I would like to remove the blog part only when on a media-tags page. So I end up with:
domain.com/media-tags/results
but the standard blog posts,categories & tags still keep the blog part of the url:
domain.com/blog/cat/post-title, domain.com/blog/cat, domain.com/tag/post-tag
Is this possible please?

I'm assuming you just need a snippet for your .htaccess file.
RewriteEngine on
# condition to avoid recursion:
RewriteCond %{REQUEST_FILENAME} !blog
# your rewrite rule:
RewriteRule media-tags blog/media-tags
When the server receives a request to domain.com/media-tags/results it will rewrite the target URL as domain.com/blog/media-tags/results.
I guess you will also have to configure your plugin to point the URLs to the root directory of your server. From the Media Tags plugin homepage:
You can also change this ‘/media-tags/’ URL parameter to something of your liking like ‘/gallery/’. To do this log into wp-admin and go to the Permalinks page under Settings. At the bottom of the page you will see the input field for Media-Tag. Simply enter your preference and update the page.

Related

how to rewrite non exist url to display content of dynamic page from wordpress

in wordpress normally if click domain.com/index.php?p=2
it redirect to domain.com/sample-page/
say now i like to show sample-page content domain.com/sample-page/
from non exist url
domain.com/member/abc/
domain.com/member/bbb/
domain.com/member/ccc/
but when user run any of above URL example.com/member/xxx/ in browser it will show content of example.com/sample-page/
without any redirection to example.com/sample-page/
so the address still remain in example.com/member/xxx/
please advice how to do in .htaccess or in functions.php
This sounds pretty straight forward, all you need is a single internal rewrite rule:
RewriteEngine on
RewriteRule ^/?member/.+/?$ /sample-page/ [END]
Such rule has to be implemented to be applied prior to the wordpress internal rules.

Wordpress menu items are not https links

I want to use https instead of http on my wordpress site. The site is now running https and there is only one problem.
short facts of my past steps.
Change the site and home url over the admin backend from http to https.
Use Search and Replace Plugin and search http://'url' and change to https://'url' for all tables and fields except the guid.
Now the issue.
My site works over https with every page but the wordpress site generate for the menu only http links. There are 3 menues of the site and every menu has only http menus. Why? How does Wordpress generate these links?
In case you never figured it out, I just did after encountering this issue lately and finding this question.
In current WP admin go to Settings > General.
Then simply add s after http.
Based on the actions you have already taken, there are two possible cases (assuming your menus haven't been defined by a plugin):
Menu links are improperly hard-coded in template files.
If this is the case, you will need to find the relevant template files in your active theme (or create a child theme) and edit them. The proper way of defining hard-coded links in this case (if they must be hard-coded) is to use template tag functions such as site_url(), which will automatically prefix links with the proper scheme and URL.
Custom links have been defined in menus, in the WP-Admin.
If this is the case, you can head to WordPress Admin --> Appearance --> Menus and edit the custom links in each of your menu items.
Have you thought about using:-
https://en-gb.wordpress.org/plugins/wp-force-ssl/
This will force all of your internal links to use https://
It's the same as #SergeyAn answer but you don't have to edit the .htaccess file directly.
You can try to use htaccess rules like this:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Force SSL on WordPress archives

I'm using the WordPress HTTPS (SSL) plugin to run my website over https, and have updated my 'WordPress Address' and 'Site Address' fields under the 'settings' menu to reflect that.
All pages and posts run over a secure connection, but archives (which I make substantial use of due to custom post types) don't. Other more traditional archive types such as tag archives act similarly.
As these are sort of pseudo pages (and don't have a physical location to tweak settings in the WP admin), is there any way of forcing these to run over SSL? Is there a trick I've missed editing .htaccess?
Many thanks in advance
You don't really need to use that plugin. And, there are several other things that should be checked to fix the archives and Custom Post Types lack of SSL.
Deactivate the plugin, clear your caches, and then change http to https in the two URL settings in WordPress Dashboard>>Settings>>General and save.
And then force SSL and www for non-SSL incoming traffic by putting these rewrite rules above the WordPress rewrite block in .htaccess:
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
That will take care of all WordPress URLs, and should take care of the Custom Post Types, too.
But check your CPT functions in functions.php or other theme files for absolute http URLs and remove the http: and leaving the //, i.e.
//fonts.googleapis.com/css?family=OpenSans
and not like
http://fonts.googleapis.com/css?family=OpenSans
Check your theme's style sheets for absolute URLs that are httpthe same way, and header links, too, i.e.:
<link href='//fonts.googleapis.com/css?family=OpenSans' rel='stylesheet' type='text/css'>
And, it's a good idea to search all your post/page content to change all http links to https for images and internal links. Changing the WordPress site URL settings to https is not enough, as that does not retroactively change all links in post/page content. Use a plugin called Search RegEx to find/replace links in post/page content. Or, use an SQL find/replace utility called interconnectit.com WordPress Serialized PHP Search Replace Tool to scan the whole database.
Lastly, use the developer tools in Firefox (or Firebug) or Chrome or Safari or IE to check for insecure element errors that are caused by images, scripts, etc., that are not loading over SSL.

URL Rewriting in Wordpress htaccess

I've built a Wordpress site that has a product page which retrieves product info from an external system using the querystring id passed in. So www.domain.com/product/?id=n loads the Wordpress product page which then loads the product info using the id.
This works fine.
However, I want to rewrite this URL so that:
www.domain.com/product/productname/id retrieves www.domain.com/product/?id=n
When I add the following to htaccess, the page returns a 404 because it doesn't exist in Wordpress.
RewriteRule ^product/productname/(.*)$ ^product/?id=$1 [L]
Does anyone know how to write this rule in such a way that it doesn't get hijacked by Wordpress rewriting?
After doing some additional searching, I've found some links that may help you get started. The secret lies in WordPress's add_rewrite_ruleshook. Haven't tried these myself yet, but looks promising:
http://codex.wordpress.org/Rewrite_API/add_rewrite_rule
URL rewriting via Wordpress Rewrite or .htaccess
http://www.hongkiat.com/blog/wordpress-url-rewrite/
http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/

Wordpress Blog URL

For some reason my blog posts are creating their own URL's.
Blog is on www.website.com/blog/ but when I make a new post, the new post URL is www.website.com/new-post-url/.
What I want is for the blog posts URL to be www.website.com/blog/new-post-url/ as their URL.
I use All in One SEO as my SEO plugin (if that matters).
You should check your blog setting.
login as administrator and go Settings >> General Settings
check here Site Address (URL). This should be http://www.website.com/blog
Hope this is helpful.
all the best ;)
#user1667462
Have you checked your .htaccess file?
Because you when you're having /blog kind of redirect to your WordPress Blog then you must have to add below code in your .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?website.com$
RewriteRule ^(/)?$ blog [L]
Go to Settings -> PermaLinks from Dashboard and select Custom Structure
give /blog/%postname%/
Check your blog by going to any post/page.
Log into your Wordpress admin panel and check to ensure that permalinks are set to the appropriate settings. Also check to make sure that your theme is not overriding the settings you might have chosen. Some themes for example can explicitly request you set a blog page for the blog posting which can interfere with what you assume to be happening.
Your go to admin page and click setting page, change the url types.

Resources