Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 03-08-2015, 05:04 PM
xms xms is offline
Junior Member
 
Join Date: 03-09-13
Posts: 44
iTrader: 0 / 0%
Exclamation .htaccess and RewriteRule problems - looking for help

Hello,

I'm using .htaccess to show existing images instead of images which does not exist.

RewriteBase /images/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)_(.*)1200x900\.jpg$ esittely_$21200x900.jpg
RewriteRule liiga1200x10.jpg esittely1200x10.jpg
RewriteRule liiga670x10.jpg esittely670x10.jpg [L]

Everyting works fine if an image does not exist.

But if an image does exist, the second RewriteRule
RewriteRule liiga1200x10.jpg esittely1200x10.jpg
will be used.

Why is that so? How could I modify my code to prevent that?

------

I also have an another problem. I have this code:

RewriteBase /images/
RewriteCond %{REQUEST_URI} ^/(.*)/(.*)$
RewriteRule liiga([0-9]{3,4})x10.jpg esittely$1x10.jpg [L]

When I'm surfing on myexamplewebsite.com/kemii/liigasu.shtml, the RewriteCond is true. Everything is OK.

When I'm surfing on myexamplewebsite.com/liigasu.shtml, the RewriteCond is true. Why is that so?
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 03-09-2015, 05:49 AM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,016
iTrader: 4 / 100%
Quote:
But if an image does exist, the second RewriteRule
RewriteRule liiga1200x10.jpg esittely1200x10.jpg
will be used.
Are you wanting it to show the 670 or what action do you want?
 
Reply With Quote
  #3  
Old 03-09-2015, 06:28 AM
xms xms is offline
Junior Member
 
Join Date: 03-09-13
Posts: 44
iTrader: 0 / 0%
Quote:
Originally Posted by ScriptMan View Post
Are you wanting it to show the 670 or what action do you want?
Let's put it this way...

RewriteBase /images/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)_(.*)1200x900.jpg esittely_$21200x900.jpg
RewriteRule (.*)1200x10.jpg esittely1200x10.jpg
RewriteRule (.*)670x10.jpg esittely670x10.jpg [L]

When I arrive to myexamplewebsite.com/liigasu.shtml (no subdirectory), I would like to skip all the RewriteRules.

When I arrive to subdirectory (for example: myexamplewebsite.com/kemii/liigasu.shtml), the RewriteRules should change these:

(.*)_(.*)1200x900.jpg -> esittely_$21200x900.jpg
(.*)1200x10.jpg -> esittely1200x10.jpg
(.*)670x10.jpg -> esittely670x10.jpg

Last edited by xms; 03-09-2015 at 06:51 AM.
 
Reply With Quote
  #4  
Old 03-09-2015, 06:49 AM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,016
iTrader: 4 / 100%
This stuff is not my specialty. I always have to muddle through it and test extensively.

Maybe this will help.

A .htaccess file affects the directory / folder in which it is placed and all children / sub directories. A .htaccess file in the parent directory can be amended or otherwise changed with a second one in a child directory. Solving this may be as simple as moving the file.

This is not relevant to your question but it is how I learned the above, the hard way.
On a shared hosting account using add on domains there must be a .htaccess file in the root folder of each domain or the master file on the primary domain affects them all.
 
Reply With Quote
  #5  
Old 03-09-2015, 06:57 AM
xms xms is offline
Junior Member
 
Join Date: 03-09-13
Posts: 44
iTrader: 0 / 0%
Thanks ScriptMan, I will think about this.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
RewriteRule Not Performing? jeffster Coding Forum 2 05-14-2011 10:59 AM
Problems with FTP and .htaccess? Raoucus Web Design Lobby 14 03-14-2011 07:34 PM
htaccess problems - GoDaddy pappu Web Hosting Forum 16 02-23-2010 06:34 PM
(Easy enough) What is the right RewriteRule inhtaccess for this... basketmen Coding Forum 0 09-10-2009 05:02 PM
Conflict, What is the right htaccess rule, default homepage file with htaccess? basketmen Coding Forum 2 01-20-2009 08:50 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:31 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC