Yii Framework Forum: Apache rewrite engine - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Apache rewrite engine Rate Topic: -----

#1 User is offline   Thomas Jensen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 150
  • Joined: 01-August 09

Posted 06 January 2010 - 04:55 AM

Hi all,

I would like to make .htaccess rewrite requests to /images/. What i want it to do is to check if the file exists as /images/bla bla, and if not, then check ../images/bla bla. I thought i could just do something like:
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(images|js)/(.*)$ ../$1/$2 [L]
RewriteRule . index.php [L]

But that doesn't seems to work. In fact, none of the files work after this. The only thing which works is the actual pages (controllers and other internal things).

Thanks in advance.
0

#2 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 06 January 2010 - 05:23 AM

You can put another .htaccess into the images folder and make the needed checks from there. I think that should work.
0

#3 User is offline   Thomas Jensen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 150
  • Joined: 01-August 09

Posted 06 January 2010 - 08:08 AM

View PostY!!, on 06 January 2010 - 05:23 AM, said:

You can put another .htaccess into the images folder and make the needed checks from there. I think that should work.


I've tried that too, but it never gets invoked.
0

#4 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 06 January 2010 - 08:34 AM

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ http://www.example.com/images/$1 [L,R=301] 


Something like this maybe? Untested.
0

#5 User is offline   cmx 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 21-November 09
  • Location:California USA

Posted 16 January 2010 - 08:41 PM

Try this:

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

0

#6 User is offline   Thomas Jensen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 150
  • Joined: 01-August 09

Posted 17 January 2010 - 03:19 PM

Sry, doesn't work :(
0

#7 User is offline   cmx 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 21-November 09
  • Location:California USA

Posted 17 January 2010 - 05:45 PM

View PostThomas Jensen, on 17 January 2010 - 03:19 PM, said:

Sry, doesn't work Posted Image


Is mod_rewrite.so enabled in your httpd.conf file?
0

#8 User is offline   Thomas Jensen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 150
  • Joined: 01-August 09

Posted 17 January 2010 - 07:50 PM

Yes, I've already done a lot of rewriting.
0

#9 User is offline   webscriptz.be 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 24-August 09
  • Location:OLW WAVER, Belgium

Posted 04 February 2010 - 05:01 AM

Did you restart your server after having enabled mod_rewrite? It is something i myself forget from time to time.
0

#10 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 04 February 2010 - 08:22 AM

You can also enable a debug log for mod_rewrite. Helps with tough issues:
http://www.latenight...bug-mod_rewrite
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users