Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
March 11, 2010, 09:12:04 PM

Pages: [1]   Go Down
  Print  
Author Topic: htaccess redirect problems with subfolder and images  (Read 622 times)
ericzad
Newbie
*
Offline Offline

Posts: 3


« on: June 25, 2009, 04:51:30 AM »

Installed wordpress in it's own folder and did htaccess to redirect to the wordpress index page. Problem is now the images don't show.

Site: www.wayneglessner.com   redirected to go to www.wayneglessner.com/wp/

When I type in a direct addy for one of the images it redirects and screws up:
Image: www.wayneglessner.com/wp/wp-content/themes/magazine-basic/images/blackdot.png

I get a 404 and this is the addy it directs it to:
http://wayneglessner.com/home/wayne0/public_html/www.wayneglessner.com

htaccess, so far:

RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^(www.)?wayneglessner.com$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^(www.)?wayneglessner.com$
RewriteRule ^(/)?$ wp/index.php [L]

AddHandler server-parsed .html
AddType video/x-ms-wmv wmv
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|psd)$ www.wayneglessner.com [R,NC]


# BEGIN WordPress

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://wayneglessner.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://wayneglessner.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.wayneglessner.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.wayneglessner.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.wayneglessner.com/wp/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.wayneglessner.com/wp$      [NC]
RewriteRule .*\.(.*)$ - [F,NC]

# END WordPress

Help...
Thanks,
Eric
Logged
MrPhil
Professor in Nanotechnology
*****
Offline Offline

Posts: 4582



« Reply #1 on: June 25, 2009, 10:52:48 AM »

This is a badly messed up .htaccess file. Let's go over the problems...

In your first section, you say
  IF the domain is www.wayneglessner.com OR wayneglessner.com  AND
   the URI does NOT start with /wp/  AND
   it's NOT a legitimate FILE  AND
   it's NOT a legitimate DIRECTORY  THEN
insert /wp/ before whatever the user typed in.

This section is not firing for you. The "!-f" and "!-d" are normally used for dealing with 404 type errors, and shouldn't be mixed in with this section.

The next section checks for www.wayneglessner.com or wayneglessner.com, and tries to send an empty request (just the domain) to wp/index.php. This was not tested in your example. Once you get the previous section working, this one may become redundant.

The AddHandler and AddType rules should be moved out from within the URL rewriting code, just for cleanliness.

The next line seems to be at least part of your problem. For any image file, you're sending to directory "www.wayneglessner.com", which is probably not what was intended. What are you trying to do? Was this derived from some hotlink protection code?

Finally, in the Wordpress section (which appears to be hotlink protection for all files that contain a "."), you could cut the final 6 tests down to one. First of all, the last two will never fire because I don't think that the HTTP_REFERER is going to have the URI (wp/...). Isn't it just the referring domain? Anyway, you can condense them down to

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?wayneglessner\.com(/)?.*$      [NC]
Logged

Pages: [1]   Go Up
  Print  
 
Jump to: