WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 5 days ago

#12002 reopened enhancement

Multisite should not lock the root blog into using a /blog prefix

Reported by: wpmuguru Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Bootstrap/Load Keywords:
Focuses: multisite Cc:

Description

MU Trac Ticket: http://trac.mu.wordpress.org/ticket/409

I don't think WPMU should lock the root blog into using a /blog prefix on permalinks. Currently, the /blog on the beginning of permalinks is hardcoded.

I realise this was probably added to stop conflicts when not using a VHOST solution, but when using VHOST to put other blogs into subdomains, why lock the root blog's permalinks as such?

Could the /blog requirement be removed if VHOST is 'yes'?

Attachments (4)

12002.diff (2.9 KB) - added by kawauso 4 years ago.
'ms_blog_prefix' filter
12002.2.diff (2.9 KB) - added by kawauso 4 years ago.
As before, no unclosed comment block
12002.3.diff (1.3 KB) - added by jeremyfelt 21 months ago.
12002.4.diff (3.3 KB) - added by jeremyfelt 21 months ago.

Download all attachments as: .zip

Change History (42)

comment:1 @wpmuguru6 years ago

The vhost configuration was addressed in http://trac.mu.wordpress.org/changeset/1104.

comment:2 @wpmuguru6 years ago

See http://core.trac.wordpress.org/ticket/11766 for additional considerations for patching this.

comment:3 @wpmuguru5 years ago

  • Milestone changed from Unassigned to 3.1

comment:4 @Denis-de-Bernardy5 years ago

  • Milestone changed from 3.1 to 3.0
  • Type changed from enhancement to defect (bug)
  • Version set to 3.0

Adding the info from #11766:

avoid_blog_page_permalink_collision() only checks for collisions with static pages.

to avoid further potential collisions, it should add an additional filter, to start with. and it should also try:

  • attachments in the event the main blog uses the /%postname%/ structure.
  • categories, tags, etc in the event a plugin strips their respective stubs
  • anything that is not a post, page, attachment or revision, and which has no parent.

comment:5 @wpmuguru5 years ago

  • Milestone changed from 3.0 to 3.1

comment:6 @wpmuguru5 years ago

  • Type changed from defect (bug) to enhancement

Comment from #11766:

Replying to wpmuguru:

If custom permalinks are using in MU folder install /blog is added to the beginning of the permalinks base (ex. /blog/%postname%/) on the main blog.

The only blog collision that might occur is with pages because they are not offset with /blog. In a non-vhost install:

page name on the main blog -> news -> http://domain.com/news/
blog name -> news -> http://domain.com/news/

comment:7 @nacin5 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:8 @djio4 years ago

  • Cc wordpress@… added
  • Component changed from Multisite to Permalinks
  • Keywords needs-patch added
  • Severity changed from normal to blocker
  • Summary changed from WPMU should not lock the root blog into using a /blog prefix on permalinks to Option to /blog prefix on permalinks
  • Version changed from 3.0 to 3.2

Just to pont a real life situation:
Where I come from, and I mean Brazil, major companies block some words like hot, sex, porn, fuck, and also blog to avoid waste of employees labor time with "minor distractions". So, the employees can't access blogspot and so, but they can't also access their own company's posts because of the infamous mandatory /blog/ prefix

I don't mean creative or development companies, but any other market or industry. It's sad but true. I encounter myself in the position of a long-time developer facing this same problem over and over: when I offer Multisite solutions using WP to my clients I must always ask how is their proxy/firewall policy agains the 'blog' word, and most of the time people won't change the policy so I must find another solution. I believe that in this case hardcoding a solution will never be a solution, because I'll lose it in next WP update.

My idea for a solution is to set this "compatibility mode to avoid conflicts" as an option in the main settings page. In addition the word 'blog' should be optional too, if I prefer 'news' instead (or any other), there would be no problem with proxies, blockers, etc.

As a conclusion, each scenario is different, we cannot impose a (commonly blocked) word as a mandatory prefix if we want to keep growing in the professional market.

---

I tried removing the /blog/ completely in the code but my website just ignores it, please check
www.djio.com.br in the categories sidebar widget: every category has a /blog/ prefix and it doesn't work if a manually remove the prefix i the URL.

I usually help the community with Localizations of WP Core and Plugins (GlotPress, etc.) but I didn't want to mess with anything submiting a patch without knowing exactly the implications, so I ask, what exactly files deal with /blog issue?

comment:9 @nacin4 years ago

  • Component changed from Permalinks to Multisite
  • Severity changed from blocker to normal
  • Version changed from 3.2 to 3.0

"Version" is the earliest version something affects. In this case it would be MU, or 3.0.

This is, at its core, a Multisite ticket.

I'm changing back the title, as it was more descriptive previously.

I'm removing the severity, as this is not a blocker for release. You *can* remove /blog/ completely at the moment, it's collision detection that's missing. Indeed, this is an enhancement, not a bug.

comment:10 @nacin4 years ago

  • Summary changed from Option to /blog prefix on permalinks to Multisite should not lock the root blog into using a /blog prefix

comment:11 follow-up: @wpmuguru4 years ago

Looking forward to 3.3 - what if the /blog was only forced when a custom structure is used? If the permalinks are set to any of the presets, then a clash with pages is extremely unlikely.

That would be relatively light changes compared to doing a complete rework. I'd be up for it for early 3.3.

comment:12 follow-up: @djio4 years ago

Thanks again for the enlightenment, Nacin!
=)

wpmuguru, I usually use /%category%/%postname%/ with some serious cache activated.
But if I heard right, this structure today uses lots os process in the server side and might be avoided.

This would be a bonus to have this set as a preset, I found this permalink structure very effective to SEO.
Is there any chance you consider dealing with this to 3.3?

Thanks in advance!

comment:13 in reply to: ↑ 12 ; follow-up: @wpmuguru4 years ago

Replying to djio:

wpmuguru, I usually use /%category%/%postname%/ with some serious cache activated.
But if I heard right, this structure today uses lots os process in the server side and might be avoided.

This would be a bonus to have this set as a preset, I found this permalink structure very effective to SEO.

Sorry, I was not suggesting that we add presets. I was referring to the presets that are currently there. The /blog is there to prevent collisions when a custom structure like /%category%/%postname%/ is used.

Adding a range of presets similar to that one would not alleviate the collision issue. Nor would it address the potential performance issues associated with some custom structure choices.

comment:14 in reply to: ↑ 13 ; follow-up: @djio4 years ago

Replying to wpmuguru:

Adding a range of presets similar to that one would not alleviate the collision issue. Nor would it address the potential performance issues associated with some custom structure choices.

I undestand they are separated issues... maybe I didn't put it right.

It seems you are familiar with this part of the core, so I was asking if you could deal with this performance issue while using custom permalink structures as well. But this is another task and probably there's already a ticket for it.

Thanks for the respondes.
Look forward to the next version.

comment:15 in reply to: ↑ 14 @wpmuguru4 years ago

Replying to djio:

It seems you are familiar with this part of the core, so I was asking if you could deal with this performance issue while using custom permalink structures as well. But this is another task and probably there's already a ticket for it.

The performance issue with some of the custom structures exists in single WP sites as well as networks and is completely unrelated to the /blog issue which is subdirectory network specific.

comment:16 in reply to: ↑ 11 @wpmuguru4 years ago

Replying to wpmuguru:

Looking forward to 3.3 - what if the /blog was only forced when a custom structure is used? If the permalinks are set to any of the presets, then a clash with pages is extremely unlikely.

This is out as a potential solution - super admins can create blogs that are just numbers (ex. 2011).

@kawauso4 years ago

'ms_blog_prefix' filter

comment:17 @kawauso4 years ago

Attached patch with what headway I've managed to make on this.

It introduces a 'ms_blog_prefix' filter which defaults to '/blog', as well as simplifying avoid_blog_page_permalink_collision() and forcing it to check any post types that aren't public rather than just pages. The various permutations of permalinks, the odd structure of attachment permalinks and any kind of taxonomy aren't accounted for.

Last edited 4 years ago by kawauso (previous) (diff)

comment:18 @djio4 years ago

Thanks kawauso for the patch!
Hope it be revised and published sometime before 3.3.
=)

Last edited 4 years ago by djio (previous) (diff)

comment:19 @SergeyBiryukov4 years ago

  • Keywords has-patch added; needs-patch removed

@kawauso4 years ago

As before, no unclosed comment block

comment:20 @kawauso4 years ago

  • Keywords needs-patch added; has-patch removed

Last patch somehow ended up with an unclosed comment block. Marking ticket as needs-patch again after chatting to westi as it still needs work to cover:

  • Attachment permalinks (that change depending on whether they're attached, though they could just always be checked)
  • Taxonomy slugs
  • Custom permalink structures
  • Any other permalink bases used by the main site

comment:21 @dwc4 years ago

  • Cc danieltwc@… added

comment:22 @Ipstenu4 years ago

  • Cc ipstenu@… added

comment:23 @JPry3 years ago

  • Cc jeremy.pry@… added

comment:24 @knutsp3 years ago

  • Cc knut@… added

comment:25 @ryanduff3 years ago

  • Cc ryan@… added

comment:26 @mindctrl3 years ago

  • Cc mindctrl added

comment:27 @mordauk2 years ago

  • Cc pippin@… added

@jeremyfelt21 months ago

@jeremyfelt21 months ago

comment:28 @jeremyfelt21 months ago

It'd be fun to start doing something with collision detection here with the side effect of ditching the /blog prefix.

12002.4.diff is a refresh of the patch from 2 years ago. I haven't had a chance to fully test it yet.

comment:29 @jeremyfelt19 months ago

  • Component changed from Multisite to Bootstrap/Load
  • Focuses multisite added

comment:30 @ocean9012 months ago

#29039 was marked as a duplicate.

comment:31 follow-up: @SergeyBiryukov8 months ago

#30712 was marked as a duplicate.

comment:32 in reply to: ↑ 31 @karincom8 months ago

Replying to SergeyBiryukov:

#30712 was marked as a duplicate.

Thank you indeed for the work you are doing.

Wordpress Multisite -> Subfolders Installation -> Permalink Structure

Being unable to find a way to replace the '/blog' slug in root domain, I am using a cron job to update the rewrite rules as work around ('/blog' to '/en').

SQL QUERIES... /blog to /en slug on root blog, multisite, subfolders installation

UPDATE bb_options
SET option_value=replace(option_value,'blog/','en/')
WHERE option_name = 'permalink_structure';

UPDATE bb_options
SET option_value=replace(option_value,'blog/','en/')
WHERE option_name = 'category_base';

UPDATE bb_options
SET option_value=replace(option_value,'blog/','en/')
WHERE option_name = 'tag_base';
 
UPDATE bb_options
SET option_value=replace(option_value,'blog/','en/')
WHERE option_name = 'rewrite_rules';

It is working beutifully in my site.

So, '/blog' slug is hardcoded for the root blog.
But... it is very easy to change, so, it should be easy to create such parameter.

REQUEST
Why not include such parameter in wp-config.php? At least for subfolders installation.

if (empty($parameter)) {$parameter='blog/';}

So, not allow it to be empty, for avoiding collisions or things like that.
Just ideas... eventually not that easy.

THanks for reading this.

Last edited 7 months ago by karincom (previous) (diff)

comment:33 follow-up: @MeharBhagat7 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

Works for me on WP version 4.1

wp-admin -> options-permalink.php ->

if ( is_multisite() && !is_subdomain_install() && is_main_site() )
	$blog_prefix = ''''/blog'''';

Change '/blog' to '/AsYouWish'

Last edited 7 months ago by dd32 (previous) (diff)

comment:34 @dd327 months ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

comment:35 in reply to: ↑ 33 @karincom7 months ago

  • Keywords needs-patch removed

Replying to MeharBhagat:

Works for me on WP version 4.1

wp-admin -> options-permalink.php ->

if ( is_multisite() && !is_subdomain_install() && is_main_site() )
	$blog_prefix = ''''/blog'''';

Change '/blog' to '/AsYouWish'


Even simpler:

if (empty($blog_prefix)) {$blog_prefix = ''''/blog'''';}

Now, we need a place to entry $blog_prefix parameter:

a) wp-config.php
b) Super-Admin Dashboard -> General Settings.

$blog_prefix input interface (for root blog) can be only seen if is_multisite() && !is_subdomain_install(). For other blogs (not the root one), you always see that interface.

It should work... and it looks like a simple udate.
Currently, my cronjob works beutifully. Of course, just a workaround.

Last edited 7 months ago by karincom (previous) (diff)

comment:36 @apsolut5 months ago

any way we can use

if ( is_multisite() && !is_subdomain_install() && is_main_site() )
	$blog_prefix = ''''/blog'''';

inside functions.php, so we dont edit core files ?

comment:37 follow-up: @jjabba5 days ago

Is there any progress on this issue? I would love to be able to change the /blog/* slug on the main blog in my newly installed network. I know a bit of php so perhaps I could help out?

comment:38 in reply to: ↑ 37 @atomicjack5 days ago

Replying to jjabba:

Is there any progress on this issue? I would love to be able to change the /blog/* slug on the main blog in my newly installed network. I know a bit of php so perhaps I could help out?

Feel free to do so - use version control to create .diff or .patch files to show the modified code.

Note: See TracTickets for help on using tickets.