Forum Moderators: phranque

Message Too Old, No Replies

Image Rewrite Problem

vbseo broken image link

         

rogerzzz

3:01 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



M new to web hosting specially to vbseo. I have a broken image problem with one of my vbulletin styles(or skins. Just have a look at it:

[url]http://www.example.net/hollywood-movies-zone/[/url]

when i click a broken image's properties, i can clearly notice a wrong rewrite url i.e

http://www.example.net/hollywood-movies-zone/images/colortheory/misc/navseperator.gif

Infact it should look like this instead which is correct location of img:

http://www.example.net/images/colortheory/misc/navseperator.gif

Is it a problem with my .htaccess or vbseo setting please help.I m using vbseo default rewrite setting.Here is the .htaccess rules i m using:

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.example\.net
RewriteRule (.*) http://www.example.net/$1 [L,R=301]

RewriteRule ^((urllist¦sitemap_).*\.(xml¦txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

RewriteCond %{QUERY_STRING} !vbseourl=
RewriteCond %{REQUEST_URI} !(admincp/¦modcp/¦chat¦cron)
RewriteRule ^(.*\.php(/.*)?)$ vbseo.php?vbseourl=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !\.(jpg¦gif)$
RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(admincp¦modcp¦clientscript¦cpstyles¦images)/
RewriteRule ^(.+)$ vbseo.php?vbseourl=$1 [L,QSA]
-------------------------------------------------------------

Thanks in advance

[edited by: jdMorgan at 4:30 pm (utc) on June 12, 2008]
[edit reason] example.net [/edit]

jdMorgan

4:35 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This line in the last rule, won't work because you've got it start-anchord, but have not accounted for the full server filepath:

RewriteCond %{REQUEST_FILENAME} !^(admincp¦modcp¦clientscript¦cpstyles¦images)/

What was probably intended is:

RewriteCond %{REQUEST_URI} !^/(admincp¦modcp¦clientscript¦cpstyles¦images)/

(note the leading slash as well)

For efficiency's sake, put this RewriteCond ahead of the other two, so as to avoid unnecessary calls to the filesystem to check for file-and-directory exists; These are *very* slow operations compared to Apache-internal operations, and should be avoided whenever possible.

Replace all broken pipe "¦" characters with solid pipes before use; Posting on this forum modifies the pipe characters.

Jim

rogerzzz

6:34 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



Jim u explained it very nicely but i m too stupid to understand :(
I m a newbie in web hosting. <snip>

[edited by: jdMorgan at 6:58 pm (utc) on June 12, 2008]
[edit reason] No email addresses or URLs, please. See TOS. [/edit]

jdMorgan

7:32 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can find links to tutorials in our Forum Charter, and in the Apache section of the WebmasterWorld Library (See links at top of every page here).

Jim

rogerzzz

1:47 pm on Jun 13, 2008 (gmt 0)

10+ Year Member



Thanks Dear Jim

Actual problem is still not sorted out buddy. I m using vBseo as my URL rewriter.
Wht exactly is happening is tht its replacing/rewriting:

www.example.com/Thread-Title-As-Url/images/colortheory/misc/image.file

Wht i m intending to do is to remove tht thread-title-As-Url from the image Url which is a wrong location. Now i can prevent images folder url to be rewritten but how can i prevent anything before it.

My VB skin's image location is images\colortheory\

Its getting all other .gif files from the right location like example.com\images\colortheory\buttons\newthread.gif etc. as i look at the image properties.
Here is the new .htaccess i m using after ur advice.I still didnt figured out where exactly is the problem, in vBseo setting or .htaccess.

Please tell me wht else should i add to this file & wht should be its location in the file:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteRule (.*) http://www.example.com/$1 [L,R=301]

RewriteRule ^((urllist¦sitemap_).*\.(xml¦txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

RewriteCond %{QUERY_STRING} !vbseourl=
RewriteCond %{REQUEST_URI} !(admincp/¦modcp/¦chat¦cron¦image)
RewriteRule ^(.*\.php(/.*)?)$ vbseo.php?vbseourl=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !\.(jpg¦gif)$
RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1 [L,QSA]

RewriteCond %{REQUEST_URI} !^/(admincp¦modcp¦clientscript¦cpstyles¦images)/*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(admincp¦modcp¦clientscript¦cpstyles¦images¦colortheory)/
RewriteRule ^(.+)$ vbseo.php?vbseourl=$1 [L,QSA]

------------------------------------------------------------------
Now this problem is killing me :'(
is there any way tht i confine the site to fetch all my .gif from a static path?

jdMorgan

3:55 pm on Jun 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, the problem is that mod_rewrite has nothing to do with creating the links on your pages. mod_rewrite comes into play only after a link is clicked and requested from your server. So I'd look into vbseo (which I'm not personally familiar with -- sorry) to see if there are any setting that might possibly address the incorrect image links on your pages.

You code appears to have several "little errors" in it, and you have not made the corrections that I suggested above. Please understand that the contributors here are all volunteers, and that we're talking about your site here; It's your responsibility to learn enough about mod_rewrite to fix it. While mod_rewrite may seem trivial and unworthy of time investment, I must point out that it is a server configuration file -- That is to say, it *must* be correct, or you will have many problems. One single typo can cause unexpected operation or intermittent errors at best, and a total loss of your search engine rankings at worst.

However, if you have no interest in learning the nitty-gritty of mod_rewrite and serve config, I'd recommend hiring a consultant to fix your server -- and having said so, recuse myself from that pool on the basis of conflict of interest.

Now, although the problem appears to be caused by a problem with how vbseo constructs links on your pages, it is possible to "put a band-aid" on the problem by using mod_rewrite to "re-connect" the bad URLs with the proper file locations on the server. I call this a "band-aid" because it does not cure the original problem -- it is only a work-around. And additionally, it causes a problem itself: Each image on your server will end up with an essentially infinite number of URLs, a problem in the duplicate-content class, and a potential point of exploitation by your competitors, detractors, or just wise-guys...

Let's clean this up a bit first, and then address the band-aid:


RewriteEngine on
# removed default/redundant "RewriteBase /"
#
# escape all literal periods in regex patterns
RewriteCond %{HTTP_HOST} !^www\.exampl[b]e\.c[/b]om
RewriteRule (.*) http://www.example.com/$1 [L,R=301]
#
RewriteRule ^((urllist¦sitemap_).*\.(xml¦txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
#
# add leading slash to 2nd RewriteCond, as previously noted
RewriteCond %{QUERY_STRING} !vbseourl=
RewriteCond %{REQUEST_URI} [b]!/(a[/b]dmincp/¦modcp/¦chat¦cron¦image)
RewriteRule ^(.*\.php(/.*)?)$ vbseo.php?vbseourl=$1 [L,QSA]
#
RewriteCond %{REQUEST_FILENAME} !\.(jpg¦gif)$
RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1 [L,QSA]
#
# fix last RewriteCond and move it to the top as previously noted -- but
# there now seems to be partial duplication with the first? Pick one.
RewriteCond %{REQUEST_URI} !^/(admincp¦modcp¦clientscript¦cpstyles¦images)/
RewriteCond %{REQUEST[b]_URI[/b]} [b]!^/(a[/b]dmincp¦modcp¦clientscript¦cpstyles¦images¦colortheory)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) vbseo.php?vbseourl=$1 [L,QSA]

Now for the band-aid:

What you apparently need to do is to drop the initial part of the URL-path for image requests if the second URL-path-part is "/images". Easy enough with a single rule, inserted above the final rule in the code block above:


RewrteRule ^[^/]+/(images/([^/]+/)*[^.]+\.(gif¦jpe?g))$ /$1 [L]

The pattern reads: "Match one or more characters not a slash, followed by a slash, followed by "images/", followed by any number (including zero) of instances of (one or more characters not a slash, followed by a slash), followed by one or more characters not a period, followed by a period, followed by and ending with either 'gif', 'jpg', or 'jpeg', while including all of this except for the initial path-part in back-reference $1."

So, the rule takes a request for the URL
/<any-initial-dir>/images/<any-number-of-dir-levels/<image-name>.<gif, jpg, or jpeg> and rewrites
it to the filepath /images/<any-number-of-dir-levels/<image-name>.<gif, jpg, or jpeg>

As stated above, you can use this to get your site working temporarily, but I cannot recommend it as a long-term fix -- Look to the vbseo code (and possibly to their help forum) to find the root cause of the incorrect image URLs on your pages.

Jim

rogerzzz

2:55 pm on Jun 15, 2008 (gmt 0)

10+ Year Member



So nice of u Jim and a special thanks to all u guys who spend their precious time discussing about my problem. Bundle of thanks.

But this doesn't fixed my problem. I m a PHP expert n i solved it in another manner. I change the way my vBulletin's template calls for image. I changed all image calls from src="images/colortheory/misc/example.gif" to this src="$stylevar[imgdir_misc]/example.gif
everything is fixed now and many thanks to all u guys once again. Keep up the good work.