|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
|||
|
|||
|
Can you check the access/rewrite logs?
They should be able to help you get an idea about what is going on. |
|
#3
|
||||
|
||||
|
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]
|
|
#4
|
|||
|
|||
|
Okay. Does everything work as it should now?
Last edited by Sarah_S : June 2nd, 2009 at 03:13 PM. |
|
#5
|
||||
|
||||
|
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... |
|
#6
|
|||
|
|||
|
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? |
|
#7
|
||||
|
||||
|
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... |
|
#8
|
||||
|
||||
|
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 ... |
|
#9
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > mod_rewrite - Where do that 404 comes from? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|