Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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 June 2nd, 2009, 10:47 AM
pixeline's Avatar
pixeline pixeline is offline
King of RGB
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brussels
Posts: 398 pixeline User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 1 m 52 sec
Reputation Power: 6
mod_rewrite - Where do that 404 comes from?

Hello !

I followed the mod_rewrite guide (thanks for the effort guys!) but i can't seem to understand what i'm doing wrong exactly:

Here is my mod_rewrite call:
Code:
#required by ovh.com hosting
SetEnv ZEND_OPTIMIZER 0
SetEnv PHP_VER 5
SetEnv REGISTER_GLOBALS 0
RewriteEngine on
IndexIgnore *
Options +FollowSymLinks

#force the use of a trailing slash
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://domain.com/$1/?%{QUERY_STRING} [NC,R,L]
RewriteRule ^/(.*)/(.*)/$ article2.php?i=$1&s=$2& [L,NC]
RewriteRule ^/([a-z0-9._\-]+/)/$ article2.php?i=$1 [L,NC]

if i point the browser to http://domain.com/46/34/ it says "404". My guess is that it is actually looking for that folder and since it does not exist, it returns the 404, instead of complying to the rewrite rule.
Note that the trailing slash redirect works fine.

What am i doing wrong?

Thank you for your time,

Alexandre
__________________
http://www.pixeline.be
........................................

Reply With Quote
  #2  
Old June 2nd, 2009, 01:56 PM
Sarah_S Sarah_S is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 197 Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 3 Days 54 m 11 sec
Reputation Power: 275
Can you check the access/rewrite logs?

They should be able to help you get an idea about what is going on.

Reply With Quote
  #3  
Old June 2nd, 2009, 03:07 PM
pixeline's Avatar
pixeline pixeline is offline
King of RGB
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brussels
Posts: 398 pixeline User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 1 m 52 sec
Reputation Power: 6
unfortunately, i dont' have access to the rewriteLog, but i found out that this works better for me:

Code:
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://domain.com/$1/?%{QUERY_STRING} [NC,R,L]
RewriteCond %{REQUEST_URI} !^/(admin|_css|_js|_img|about|legal)/.*$
RewriteRule ^([^/]+)/([^/]+)/?$ article2.php?i=$1&s=$2& [L,NC]

Reply With Quote
  #4  
Old June 2nd, 2009, 03:11 PM
Sarah_S Sarah_S is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 197 Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 3 Days 54 m 11 sec
Reputation Power: 275
Okay. Does everything work as it should now?

Last edited by Sarah_S : June 2nd, 2009 at 03:13 PM.

Reply With Quote
  #5  
Old June 2nd, 2009, 03:34 PM
pixeline's Avatar
pixeline pixeline is offline
King of RGB
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brussels
Posts: 398 pixeline User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 1 m 52 sec
Reputation Power: 6
yes it does, thanks! I have just an issue to have this working too:
Code:
RewriteRule ^([^/]+)/?$ issue.php?i=$1 [L,NC]

if i add it, then ALL my urls point to issue.php. I'm trying my way around it for the moment...

Reply With Quote
  #6  
Old June 2nd, 2009, 03:42 PM
Sarah_S Sarah_S is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 197 Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 3 Days 54 m 11 sec
Reputation Power: 275
For example "something.htm" or "something/" (but not "something/else.htm") will redirect to issue.php, yeah.
What would you like it to do instead?

Reply With Quote
  #7  
Old June 2nd, 2009, 04:00 PM
pixeline's Avatar
pixeline pixeline is offline
King of RGB
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brussels
Posts: 398 pixeline User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 1 m 52 sec
Reputation Power: 6
ok i've taken your comment literaly

I will now have

/pseudo-folder/pseudo-file.html >> article.php?i=$1&s=$2

and
/pseudo-folder/ >> issue.php?i=$1

i've managed the first one. I'm working on the second one. problem is it overrule the other rules. i'm close though...

Reply With Quote
  #8  
Old June 2nd, 2009, 04:12 PM
pixeline's Avatar
pixeline pixeline is offline
King of RGB
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brussels
Posts: 398 pixeline User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 1 m 52 sec
Reputation Power: 6
for the moment my htaccess is this:

Code:
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://domain.com/$1/?%{QUERY_STRING} [NC,R,L]
RewriteCond %{REQUEST_URI} !^/(admin|_css|_js|_img|about|legal)/.*$
RewriteRule ^issues/([^/]+)?$ issues.php?i=$1 [L,NC]
RewriteRule ^issues/$ issues.php [L,NC]
RewriteRule ^([^/]+)/([^/]+)\.html$ article.php?i=$1&s=$2 [L,NC]


"domain.com/issues/slug-part/" gives me 404 ...

Reply With Quote
  #9  
Old June 2nd, 2009, 04:59 PM
Sarah_S Sarah_S is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 197 Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level)Sarah_S User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 3 Days 54 m 11 sec
Reputation Power: 275
How about this?
Code:
RewriteRule ^issues(?:/([^/]+))?/?$ issues.php?i=$1 [L,NC]
RewriteCond %{REQUEST_URI} !^/(admin|_css|_js|_img|about|legal)/
RewriteRule ^([^/]+)/([^/]+)\.html$ article.php?i=$1&s=$2 [L,NC]


Tested it.
/issues/slug-part/ -> issues.php
/admin/test.html -> test.html
/something/else.html -> article.php

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > mod_rewrite - Where do that 404 comes from?


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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
Stay green...Green IT