Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.