Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For our school, we use a wordpress network. The main domain gives access to general information and sub-sites are specific projects managed by students.

I would like that all sub-sites have their url appended with a fake folder name.

example

Say the main domain is school.edu

My sub-sites are

school.edu/project1/
school.edu/project2/

I would like that it becomes:

school.edu/projects/project1/
school.edu/projects/project2/

How can i do it?

UPDATE 1

I tried adding this rule to my .htaccess. It redirects correctly, but then the displayed URL doesn't stay the one i want, it reverts back to the original "real" url.

RewriteRule ^projects/([_0-9a-zA-Z-]+/)? $1 [R=301,L]
share|improve this question
    
Have you tried removing R=301, from the .htaccess RewriteRule? –  bungeshea Dec 28 '12 at 22:13
    
yes, it doesn't change the fact that it reverts back to the original real url. –  pixeline Dec 29 '12 at 0:04
    
Do you have Options FollowSymlinks or Options +FollowSymlinks anywhere in your .htaccess file? If so, remove it. If not, add it to above the rewrite rule –  bungeshea Dec 29 '12 at 8:37
    
tried both with and without options followsymlinks. No go. If you have a working example i'd love to see it. –  pixeline Dec 30 '12 at 9:32

3 Answers 3

I had a similar issue with another client, entering something like projects/project1 would error as the / would fail validation.

After failing to find an override or filter, instead I found a loophole. If you make projectsproject1, then afterwards edit the site so its url is projects/project1 and save, update the homeurl etc, it works! You may need to make modifications to htaccess etc however to prevent attachments failing to load, but that should be less of an issue now that 3.5 skips ms-files.php

share|improve this answer
    
It doesn't work for my installation apparently. –  pixeline Dec 20 '12 at 20:12
    
At which part does it fail? If push comes to shove, modify the URL in the database using the sites table, and the options table for that site, then refresh permalinks. Remember you'll need to make adjustments to htaccess and possibly sunrise.php too –  Tom J Nowell Dec 20 '12 at 22:04
    
You will definitely need to make changes to sunrise.php, can you get back to me and let me know what happened when you tried my suggestion? "It didn't work" isn't very descriptive, and simply modifying htaccess rules isn't enough, the DB needs to change, and WordPress needs to be able to know to look for that blog/site ( hence sunrise.php changes ) –  Tom J Nowell Dec 21 '12 at 10:20
    
"it didn't work" means: the generated permalink (after the "edit the site so its url is projects/project1 and save" step, redirects back to the main blog. It does not points to the intended sub blog. –  pixeline Dec 21 '12 at 20:56
    
hmmm not quite sure what you mean there, I can think of several things you could mean from that sentence that are not the same. Do you mean you now have a site with the URL you desire, but navigating there gives you the root site, not the subsite? –  Tom J Nowell Dec 21 '12 at 21:05

You may try solving this with using .htaccess modifications alone. You could rewrite any URL school.edu/projects/project2/ to school.edu/project2/ and use the long format. But in this case you also need the generate the proper long URLs in Wordpress.

share|improve this answer
    
I gave a shot at your suggestion. Please see update1. It might work but not sure how to improve my rewrite rule exactly. –  pixeline Dec 20 '12 at 20:11
    
@feeela Please give an example of the rewrite rule to use –  bungeshea Dec 28 '12 at 22:27

So the way it's recommended to handle this issue for WordPress is to actually let users see the yourschool.edu/project1 url, but to put your installation into a different directory that users are less likely to find.

This means it's sort of the opposite of what you're asking, but it's the best practice answer, and it resolves what I assume the larger concern is by providing a layer of security through obscurity.

Here's what you'd do for a fresh install:

  1. download the wordpress core files (as a zip from wordpress.org)
  2. unzip it
  3. rename the folder something obscure (but that you will remember)
  4. upload the folder to the root directory of your site
  5. copy the index.php and .htaccess file from the obscurely named folder and paste into the root directory (note: the .htaccess file might not exist yet, in which case you will have to create it)
  6. open the index.php file and change

     require('./wp-blog-header.php'); 
    

to this

    require('./nameofobscurefolder/wp-blog-header.php');

This means that you will have to log in at the longer address, but chances are you already will have that on your bookmark toolbar.

Once you have installed WP and logged in, go to Settings > General

Check for two things:

  1. that the settings for your Wordpress URL point to http://yourschool.edu/nameofobscurefolder

  2. that the Blog URL points to http://yourschool.edu.

share|improve this answer
    
The reason has nothing to do with providing an additional layer of security, but for purely aesthetic purpose. The real domain and the fake folder make an url that brings additional meaning (dwm.re/garde/project-name : "regarde" is "look at" in French). Yet, there are already 9 sub-blogs so i thought it may be possible to make it only via rewriteRule. At this point i guess the best would be to have one WP for the main domain, and a network inside the "garde" folder. –  pixeline Dec 31 '12 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.