Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 11th, 2012, 03:20 AM
sergiozambrano sergiozambrano is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 16 sergiozambrano Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 3 h 7 m 50 sec
Reputation Power: 0
Unhappy Rewrite rule not ignoring not-found parameter

Can you help me find out what's wrong with this?

I'm not an Apache programmer, one of the few things I thought I do know is that -f means "is not a file", which triggers when "not found", but now i doubt it.

These are my rules, and the problem is that the verification file from google e.g. /8377rsomecode.html is not found (it's a real file, not a wordpress page)

It should be NOT catched by line marked with ***********

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)\.html http://%{SERVER_NAME}/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} =!blog/page/.*
RewriteCond %{HTTP_HOST} =!blog/tag/.*
RewriteCond %{HTTP_HOST} =!blog/category/.*
RewriteRule ^blog/(.*) http://%{SERVER_NAME}/$1 [R=301,L]
# remaining.html files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ /$1 [R=301,L]************
#
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Reply With Quote
  #2  
Old April 11th, 2012, 04:54 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,681 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 4 m 57 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Other than the bits using HTTP_HOST I don't see anything wrong. But they wouldn't have anything to do with your problem so that's not it.

Just to be clear, if you tried going to /8377rsomecode.html by yourself in a browser, you get redirected to /8377rsomecode (no extension) and then, presumably, WordPress's 404 page?

Reply With Quote
  #3  
Old April 11th, 2012, 05:25 AM
sergiozambrano sergiozambrano is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 16 sergiozambrano Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 3 h 7 m 50 sec
Reputation Power: 0
Update

when I say /something.html I mean after my domain.com of course.

Can you tell me why that will be redirected to the same thing without .html?

I believe the first redirect rules dealing with .html only does it to urls containing /blog/ and my example doesn't have it.

UPDATE: The page is not retrieved because a redirection loop, rather than not found at all.

I tried removing

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ /$1 [R=301,L]************


and it works. So the problem must be the first rule dealing with .html is either not stopping there as the parameter [L] says, or working on ALL pages, not only the ones with /blog/ in it.

Reply With Quote
  #4  
Old April 11th, 2012, 05:56 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,681 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 4 m 57 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
The Rules:
1. Redirects /blog/foo.html to /foo but only if it doesn't exist.
2. Will never fire.
3. Redirects /foo/bar/baz.html to /foo/bar/baz but only if it isn't a file.
4. Allows index.php.
5. Silently rewrites everything non-existent to index.php.

If your verification file really does exist then none of the Rules should fire.

Reply With Quote
  #5  
Old April 11th, 2012, 06:46 PM
sergiozambrano sergiozambrano is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 16 sergiozambrano Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 3 h 7 m 50 sec
Reputation Power: 0
Fixed it, but seems I still don't understand regexes in rewrites

Quote:
Originally Posted by requinix
2. Will never fire.


Why? The 6th line matches requests ending with .html but ALSO blog/
Line #14 should catch the rest of .html files (not cached before because they don't contain /blog/ )
… I'm wrong right? I can't see why, sorry

Quote:
If your verification file really does exist then none of the Rules should fire.

That's the idea.

UPDATE: I made it work by adding the following condition to the first rule:

Code:
RewriteCond %{HTTP_HOST} =/blog/.*


So why was ^blog/(.*)\.html not ignoring requests lacking blog/ ?

Was it the missing first forward slash?

Reply With Quote
  #6  
Old April 11th, 2012, 07:28 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,681 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 4 m 57 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
HTTP_HOST is the hostname of the site. Like here it's "forums.devshed.com" and on your site it's "domain.com". So

- #2 will never fire because the Conds never match. Putting aside the fact that the three of them are mutually exclusive (because Conds are all ANDed by default), they all require that the domain name is exactly (for example) "!blog/page/.*".

- What you've done now is add a condition that will never match. The domain name will never be exactly equal to "/blog/.*" thus that Rule will never fire.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Rewrite rule not ignoring not-found parameter

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap