Forum Replies Created

Viewing 15 replies - 1 through 15 (of 21 total)
  • davidem

    (@davidem)

    Damn, this works like a charm! I was looking for something like this since I migrated to WP3.0, thanks!

    Thread Starter davidem

    (@davidem)

    @mavendev: Creating subdomains and using them wasn’t the issue, but thanks for the reply 😉

    I had that yesterday as well. For me it helped to untick “Update siteurl and home as well.”

    I didn’t know that port 80 was blocked by the firewall, and in that case redirecting will be tough…

    Hacking the database isn’t necessary I think, as I suspect you can also change the Site URL from ‘SuperAdmin > Sites > <choose one> > Site Options > Siteurl.

    Ah, it appears that you have completely disabled http (80). Instead, you could allow http to reach certain redirects in Apache, like this:

    <VirtualHost <IP Adress>:80>
        ServerName domain.com
        Redirect 301 / https://domain.com
    </VirtualHost>

    Perhaps you can force https in apache?

    Hi sjcundy,

    A simple “define(‘FORCE_SSL_ADMIN’, true);” in your wp-config.php could also do the trick, but in my case it caused certificate errors, so I use apache’s mod_rewrite to get it done. More info can be found here: Admin over SSL

    For multisite, you can use the %{SERVER_NAME} variable, so the subdomains in the url stay the same.

    Only prereq is that mod_rewrite is active in apache.
    Here’s my setup:

    # https://domain.com
    <VirtualHost <IP-Address>:443>
            # I'll skip the standard stuff for SSL.
            <IfModule mod_rewrite.c>
                    # If no https is needed, revert back to http.
                    # I specifically added includes and content, because I ran into some issues with plugins.
                    RewriteEngine On
                    RewriteRule !^/wp-(admin|login|signup|includes|content)(.*) - [C]
                    RewriteRule ^/(.*) http://%{SERVER_NAME}/$1 [QSA,L]
            </IfModule>
    </VirtualHost>
    
    # http://domain.com
    <VirtualHost <IP-address>:80>
            # I'll skip the standard stuff again. Add the following rewrite lines to your Directory
            <Directory>
                    <IfModule mod_rewrite.c>
                            RewriteEngine On
                            RewriteBase /
                            # If the url leads to wp-admin/login or signup, switch to https
                            RewriteCond %{REQUEST_FILENAME} -f [OR]
                            RewriteCond %{REQUEST_FILENAME} -d
                            RewriteRule ^wp-(admin|login|signup)(.*) https://%{SERVER_NAME}/wp-$1$2 [C]
                            RewriteRule ^.*$ - [S=40]
    			# WP rules from .htaccess file, I like to keep them in one file.
    			RewriteRule ^index\.php$ - [L]
    			# uploaded files
    			RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    			RewriteCond %{REQUEST_FILENAME} -f [OR]
    			RewriteCond %{REQUEST_FILENAME} -d
    			RewriteRule ^ - [L]
    			RewriteRule . index.php [L]
                    </IfModule>
            </Directory>
    </VirtualHost>

    ps. I adjusted the above today for multisite, as I migrated myself only this week. Some brief tests showed that it works for all my subdomains. For example: I go to http://blog1.domain.com/wp-login, and it redirects me to https://blog1.domain.com/wp-login.

    Is this what you were looking for?

    Another thing you can do is make WP handle the redirecting, if you’ve installed the “WordPress MU Domain Mapping” plugin and added a wildcard (*.yourdomain.com) in apache…
    – Go to Super Admin > Options and remove ‘www’ from the banned names.
    – Go to Super Admin > Domains and fill in the main blog-id in Site ID and ‘www.yourdomain.com’ in Domain. Save and it should work.

    Thread Starter davidem

    (@davidem)

    On the other hand, Andrea_r seems to be very close to wpmuguru, one of the authors of the plugin 😉

    Thread Starter davidem

    (@davidem)

    I remember something like ‘definitely not’… 😉

    Anyway, thanks for all the feedback, it kept the topic warm… Otherwise I probably had already forgotten that I needed to figure this out…

    Thread Starter davidem

    (@davidem)

    OMG… It was right under my nose. Remember the “WordPress MU Domain Mapping” plugin you’re suggested to install during setup of WP3.0 Multisite? Well, I always thought it was mainly meant to deal with multiple domains, but…

    … It also works like a charm for sub-domains! If you’re at the ‘domains’ page, simply fill in the blog-id of for example foo.domain.com in the ‘Site ID’ field, and type bar.domain.com in the ‘Domain’ field, uncheck primary and: tadaa… it works! bar.domain.com brings you directly to foo.domain.com!

    Thread Starter davidem

    (@davidem)

    Someone asked me to set up a WP multisite installation, after I explained the new features of WP3.0, and asked me if he could simply create aliases. And as I don’t want to be called every now and then with the question if I can configure Apache again, I was wondering if WP could deal with such a thing.

    I don’t have a lot of spare time, but I’ll have a go at my first plugin 😉

    Thread Starter davidem

    (@davidem)

    Maybe you could code up an aliases plugin that says ‘Sub1 = sub2’?

    Lol… Let’s have a look at ‘Hello Dolly’ 😉

    Thread Starter davidem

    (@davidem)

    To be honest I don’t agree with the conclusion that it is an issue with Apache. Apache works fine and is set up correct, according to the setup guide from WordPress.

    The wildcard in httpd.conf sends all subdomain-requests to WordPress, so it is up to WordPress to interpret those requests. At this moment, if it doesn’t recognize a subdomain, it asks if a new site should be created. It shouldn’t be that difficult to make it understand aliases.

    And as I stated before, it already works if you want an alias for your main domain, by just make an entry in the ‘Banned Names’ section of the superadmin options.

    Thread Starter davidem

    (@davidem)

    hmm, too bad… Because for me it is not a problem to tinker with Apache’s files, but it is for the people who will use these blogs eventually.

    What’s the chance that it will end up in a future release? 😉

Viewing 15 replies - 1 through 15 (of 21 total)