You are here: Re: mod_rewrite problem « All PHP « IT news, forums, messages
Re: mod_rewrite problem

Posted by Rik Wasmus on 08/31/07 09:30

On Fri, 31 Aug 2007 11:15:57 +0200, luigi7up <luigi7up@gmail.com> wrote:=

> On 30 kol, 12:59, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>> On Thu, 30 Aug 2007 12:31:34 +0200, luigi7up <luigi...@gmail.com> wro=
te:
>> > Hello everyone,
>>
>> > Im havin' problem with images in pages that were mod_rewrite-n.
>> > /blog/3/
>> > is rewritten into
>> > index.php?kom=3Dblog&id=3D3
>>
>> > in .htaccess with directives:
>> > RewriteRule ^blog/$ index.php?kom=3Dblog [L]
>> > RewriteRule ^blog/(.*)/$ index.php?kom=3Dblog&id=3D$1 [L]
>>
>> > but images that have relative path <img src=3D'images/image.jpg' />=
are
>> > problem because server appends image path to virtual directory /blo=
g/
>> > 3/:
>>
>> As said, go for the src=3D'/images/image.jpg' solution.
>>
>> .htaccess is possible, but very kludgy.
>>
>> RewriteRule ^blog/images/(.*)$ images/$1 [L]
>> RewriteRule ^blog/$ index.php?kom=3Dblog [L]
>> RewriteRule ^blog/(.*)/$ index.php?kom=3Dblog&id=3D$1 [L]
>
> thank you,
>
> RewriteRule ^blog/images/(.*)$ images/$1 [L]
> did what I needed.

I still urge you to go for the src=3D"/images/etc" solution :).

> Now, could you tell me what would be the use of conditional:
>
> RewriteCond %{REQUEST_URI} !\.(exe|jpg|jpeg)$

It is a conditional. You can put that before a RewriteRule, to check =

wether the rule should be processed or not. So this:

RewriteCond %{REQUEST_URI} !\.(exe|jpg|jpeg)$
RewriteRule ^blog/(.*)/$ index.php?kom=3Dblog&id=3D$1 [L]

Would mean:
If the url does NOT end in '.exe','.jpg' or '.jpeg' and starts with =

'blog/' then rewrite the url to index.php?kom=3Dblog&id=3D<whatever come=
s =

after 'blog/'>. It would mean that no rewriting for those extentions wou=
ld =

take place, so it would still search in /blog/images for the (.jp(e)g) =

images, no rewriting for those would take place.
-- =

Rik Wasmus

My new ISP's newsserver sucks. Anyone recommend a good one? Paying for =

quality is certainly an option.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация