Jump to content

MVC, Image Paths, and Mod_rewrite Trouble


Emir

Recommended Posts

Hello,

 

I have having a bit of trouble getting my images to display properly when using a MVC system with mod_rewrite. I have the following in a .htaccess file:

 

RewriteEngine on

 

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

 

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

 

For the most part it works just as I want: If I type in 'http://www.mysitehere.com/users/login/' it would interpret the request as 'http://www.mysitehere.com/index.php?route=users/login'; however, the trouble I have is that now my images link to something like 'http://www.mysitehere.com/users/login/images/logo.gif'. It should be something like 'http://www.mysitehere.com/images/logo.gif'. Anyone have any ideas how I can use mod_rewrite to correct this as well? Any other method would be greatly appreciated as well.

 

Thank you for your time!

 

Emir

 

Link to comment
https://forums.phpfreaks.com/topic/90804-mvc-image-paths-and-mod_rewrite-trouble/
Share on other sites

Hey everyone,

 

Looks like I was finally able to figure out what to do. I was able to fix everything with a couple RewriteRule statements.

 

RewriteRule ^[a-zA-Z/]*/images/(.*)$ images/$1

RewriteRule ^[a-zA-Z/]*/includes/(.*)$ includes/$1

 

That pretty much fixed everything for the image, css, etc links.

 

Thanks for looking though. Maybe someone else might find this useful?

 

Emir

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.