WordPress.org

Ready to get started?Download WordPress

Forums

Pretty permalinks to subdomains rewrite HELP! (8 posts)

  1. Thorned Rose
    Member
    Posted 2 years ago #

    I've spent the last two days trying to find a solution and now I'm bordering on going bonkers!

    I have WordPress installed on mydomain.org.nz/wordpress and some pages set up with pretty permalinks as mydomain.org.nz/wordpress/services/one, mydomain.org.nz/wordpress/services/two etc.

    What I want is for people to be able to go to one.mydomain.org.nz and for it to mirror what's at mydomain.org.nz/wordpress/services/one i.e.
    They can go to mydomain.org.nz/wordpress/services/one or one.mydomain.org.nz and they will be the same (the url will stay the same as what they typed in).

    I've tried a number of different rewrite rules in the htaccess but so far it either redirects to the root mydomain.org.nz, goes to mydomain.org.nz/wordpress/ or I get a 501 internal server error that porked up all the current subdomains.

    I have tried solving this myself but as I have cognitive problems, I'm struggling to work out the needed code myself. If someone could give me the code to copy paste into the htaccess that would be very much appreciated!! Also bearing in mind that at some point mydomain.org.nz/wordpress/ will be changed to just mydomain.org.nz but the wordpress install will stay in the /wordpress/ subdirectory.

    Thanks in advance, tis much appreciated! :)

  2. Thorned Rose
    Member
    Posted 2 years ago #

    Sorry, I forgot to mention that I'm on a shared server so I cannot create wildcard subdomains but as I won't be requiring a kajillion subdomains, I don't mind entering each subdomain manually into the htaccess :)

  3. Thorned Rose
    Member
    Posted 2 years ago #

    Surely someone has even a little snippet of info? :(

  4. Thorned Rose
    Member
    Posted 2 years ago #

    Ok, well so far I have my host set up so that the subdomain points to the WordPress web directory i.e. home/user/mydomain.org.nz/wordpress
    The htaccess within that directory looks like this:

    RewriteEngine On
    RewriteBase /wordpress/
    RewriteCond %{HTTP_HOST} ^(www\.)?[^.]+\.test\.mydomain\.org\.nz.*$
    RewriteRule (.*) http://mydomain.org.nz/wordpress/services/test/$1 [L]
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]

    However that does not work. I got that code from a basic 'how to' of a rewrite a subdomain to a directory. So far I'm still at a loss as to how to get this damn thing to work and swearing at it isn't working either...

  5. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    WordPress recommends this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    in the root of your WordPress directory (same location as wp-config.php)

    Also, ask your host about the first if statement above. The mode rewrite modules must be installed and running.

    Add this to your themes header.php file to test if permalinks are on:

    <?php if ( get_option('permalink_structure') != '' ) { echo 'permalinks enabled'; } ?>

    If on, the text "permalinks enabled" will appear in the header of that page in your browser that has been refreshed for that page/site.

  6. Thorned Rose
    Member
    Posted 2 years ago #

    Yes, that's what is in the htaccess by default. But the problem isn't with getting permaliks to work - pretty permalinks work just fine. The issue is with getting a subdomain to point to a wordpress permalink URL e.g. typing in test.domain.org.nz will take you to domain.org.nz/wordpress/services/test

  7. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Typically, with most good web hosts anyway, a sub-domain is mapped using an record in the DNS setup to point to the folder associated with the sub-domain...this is web host specific, and a topic to discuss with the folks who work with domains at your web host. GoDaddy has a help page on this, of course, and again, this is web host specific.

  8. Thorned Rose
    Member
    Posted 2 years ago #

    I have the DNS settings correctly pointing to the right directory. I can't however point the subdomain to the permalink as it's not an actual directory.

Topic Closed

This topic has been closed to new replies.

About this Topic