Forums

URL rewrite issue with images in subsites redux (13 posts)

  1. greene.md
    Member
    Posted 10 months ago #

    I year ago I started this thread Images not working in subsites. It was closed so I am starting this thread to hopefully solve my issue. The issues with image uploads are still occurring, most of the info is the same as the old thread but I'll include a little here.

    current root .htaccess

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$1 [L]
    # RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    
    #protection against script injections
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    RewriteRule ^(.*)$ index.php [F,L]
    
    #compress text,html,javascript,css,xml:
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rcc+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    
    # Expires Headers - 2678400s = 31 days
    <ifmodule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 24 hours"
    ExpiresByType text/html "access plus 7200 seconds"
    ExpiresByType image/gif "access plus 2678400 seconds"
    ExpiresByType image/jpeg "access plus 2678400 seconds"
    ExpiresByType image/png "access plus 2678400 seconds"
    ExpiresByType image/ico "access plus 2678400 seconds"
    ExpiresByType text/css "access plus 1 second"
    ExpiresByType text/javascript "access plus 2678400 seconds"
    ExpiresByType application/x-javascript "access plus 2678400 seconds"
    </ifmodule>
    
    # Cache Headers
    <ifmodule mod_headers.c>
    
    # Cache specified files for 31 days
    <Filesmatch "\.(ico|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2678400, public"
    </Filesmatch>
    
    # NO CACHE for html/php files.
    <Filesmatch "\.(html|htm|php)$">
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    </Filesmatch>
    
    # Cache PDFs and CSS for a day
    <Filesmatch "\.(pdf|css)$">
    Header set Cache-Control "max-age=1, public"
    </Filesmatch>
    
    # Cache Javascripts for 31 days
    <Filesmatch "\.(js)$">
    Header set Cache-Control "max-age=2678400, private"
    </Filesmatch>
    </ifmodule>
    FileETag none

    Current /directory .htaccess

    RewriteEngine On
    RewriteBase /directory/
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    I have two mutlisite installs running on this server the root http://www.rappahannock.edu and our directory http://www.rappahannock.edu/directory. Today I did an image upload test and turned on rewrite logging and these are the results.

    [Log moderated as per the Forum Rules. Please use the pastebin]

    Identical except for lines 7-8(indented). Does anybody have any idea what is going on here?

  2. Andrea_r
    team pirate
    Posted 10 months ago #

    And it's the same fix. It's not the htaccess rules themselves, its the server not reading them. Quite common for installs in folders.

    Go into httpd.conf, add AllowOverride FileInfo Options to the vhost.

  3. greene.md
    Member
    Posted 10 months ago #

    Changing AllowOverride from All to FileInfo Options 500 errored the whole site.

  4. greene.md
    Member
    Posted 10 months ago #

    Wouldn't AllowOverride All include FileInfo and Options anyway?

  5. greene.md
    Member
    Posted 10 months ago #

    Currently have the following in my httpd.conf

    <Directory "C:/rootfolderlocation">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    httpd-vhosts.conf does not contain anything accept server name and document root rules.

  6. karabee
    Member
    Posted 10 months ago #

    I've been trying to figure out the same thing and have come across something that might be related. On my install "Page" addresses are also disabled also and have found similar language in codex troubleshooting re images not loading.

    http://www.kylecaulfield.com/permalink-for-wordpress-iis-6-mod_rewrite-fixed-free

    Will be watching this thread with interest.

  7. greene.md
    Member
    Posted 10 months ago #

  8. greene.md
    Member
    Posted 10 months ago #

    Does anybody know if there's a way to completely bypass the rewrite and allow wordpress to use the original location so that my image uploads just work?

  9. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    greene.md - Windows servers are different. What version of IIS are you using? This is very much a server issue, though. Your server isn't reading the .htaccess correctly.

    (and no, ALL doesn't include FileOptions and such... it's weird).

  10. greene.md
    Member
    Posted 10 months ago #

    @ipstenu I'm using Apache on Windows which makes me a super oddball. I'll look into the allowoverride a little more. Maybe I can find a config that doesn't 500 my website and let's image uploads work if the WordPress gods are on my side today. Thanks for that info.

  11. greene.md
    Member
    Posted 10 months ago #

    My httpd.conf now contains

    <Directory "C:/rootfolderlocation">
        Options All
        AllowOverride AuthConfig FileInfo Indexes Limit Options
        Order allow,deny
        Allow from all
    </Directory>

    But still not luck, here's the current image upload's log
    http://pastebin.com/dpW7fB97

  12. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    I re-read the old post. Oh. Now I remember :(

    Hm. Is PHP Safe Mode on?

  13. greene.md
    Member
    Posted 10 months ago #

    PHP Safe Mode is off

Reply

You must log in to post.

About this Topic