0

I want to remove a folder from my WordPress URL in a particular case:

From:

http://capitulardesign.com.br/blog/portfolio/70-anos-sinduscon/

To:

http://capitulardesign.com.br/portfolio/70-anos-sinduscon/

But the rule must work only on /blog/portfolio/ cases. The WordPress is installed on /blog/ folder and the normal website (custom PHP pages mixed with WordPress Codex codes) is in the root folder.

Plus: The /portfolio/ is a Custom Post Type taxonomy.

4 Answers4

0

That would be a really, hmmm... ineffective solution.

  1. Have you considered to alter the rewrite_rules and change portfolio "term" link with term_link?

    Check out what current rules of the portfolio using portfolio_rewrite_rules filter and change links to them using term_link filter.

  2. Another way to solve this will be to change with_front (to false) of your rewrite element of arguments array for taxonomy portfolio (while register_taxonomy).

Community
  • 1
  • 1
Oleg Butuzov
  • 2,742
  • 2
  • 15
  • 23
0

Put the following code in main root .htaccess file :

RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} !\s/+portfolio/ [NC]
RewriteRule ^blog/portfolio/(.*)$ portfolio/$1 [R=302,L,NE]
RewriteRule ^portfolio/(.*)$ blog/portfolio/$1 [L]

The scenario is to redirect any request for /blog/portfolio/ to /portfolio/ then internally redirect any /portfolio/ to /blog/portfolio/ .

Note: clear your browser cache and test it , if Ok , change 302 to 301 to be permanent redirection

Mohammed Elhag
  • 4,211
  • 1
  • 7
  • 17
-1

use better search replace plugin to replace your url. old url

http://capitulardesign.com.br/blog/portfolio/

New url

http://capitulardesign.com.br/portfolio/

No need of htaccess

David Corp
  • 376
  • 3
  • 12
  • Don't work for me, because I'm not moving the entire site from /blog/ to /, I want to change only on this particular case of URL as /blog/portfolio/ – Danilo P. da Silva Oct 08 '17 at 12:32
  • RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^capitulardesign.com.br RewriteRule ^blog/portfolio/(.*)$ portfolio/$1 [L,R=301] – David Corp Oct 08 '17 at 13:51
-1
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^capitulardesign.com.br
RewriteRule ^blog/(.*)$ blog/portfolio/$1 [L,R=301]
David Corp
  • 376
  • 3
  • 12