• I have WP Multisite running within an existing site that has a lot of html pages including index.html as the main home page. The intention is to retain a large amount of non-wp content in a number of subdirectories, and add several wp sites in addition so parts of a large site will be wp and other parts non-wp so that editing parts of the site can be delegated to colleagues who don’t write html. We are currently working on the first wp site.

    The problem I am trying to solve is an .htaccess problem. The current wp part of this is:

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ – [L]

    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ – [L]
    RewriteRule ^(wp-(content|admin|includes).*) picture-shop/$1 [L]
    RewriteRule ^(.*\.php)$ picture-shop/$1 [L]
    #Removing the line below makes intra-site quick links work but not full url redirects
    #removing the line below causes wp viewing to fail
    RewriteRule . index.php [L]

    Now this works OK for wp. But earlier in the .htaccess file I have a long list of simple redirects that provide for user-friendly URLs so the user can type https://www.canalmuseum.org.uk/groups and this redirects to https://www.canalmuseum.org.uk/visit/groups.htm

    The code is

    RewriteEngine on
    RewriteRule ^groups$ /visit/groups.htm [r=301]

    and this comes at the beginning of the .htaccess file.

    There is a conflict between these. The wp section redirects any phantom URL to index.php and the result is a 404 error using the wp 404 page. If the URL to which the user is supposed to be redirected is a complete URL I get a 301 moved permanently error.

    I want my cake and to eat it here, I want the html part of the site and my user-friendly redirects to function as if wo did not exist, but equally I want wp pages to work, which they don’t if RewriteRule . index.php [L] is removed.

    I wonder if anyone can suggest a way to make them both work?

  • The topic ‘Multisite htaccess and user-friendly redirects’ is closed to new replies.