1

I setted up a local environament using vagrant and virtualBox,

And some of this rules I have in my .htaccess (wich work in production code) will fire 404 error, when in production environament work perfectly

This one, for example works:

# hostname/posts/?show=lasts -> posts.php?show=lasts

RewriteRule ^posts/$ posts.php?$1&friendly=1 [QSA]

Won't work (404):

# hostname/page/the-title/5 -> page.php?id=5

RewriteRule ^page/(.+)/(.+) page.php?id=$2&friendly=1

Any idea what I'm missing?

hostname in production it's like page.com and in the virtual machine it's localhost:8085 in case it helps

-EDIT-

Full block:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)%20(.*)$
RewriteRule ^(.*)$ /$1?%1-%2 [L,R=301,NE]



ErrorDocument 500 /oohps.php
ErrorDocument 404 /where.php

RewriteBase /
# Quitar www
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
# Canonicación de la IP
RewriteCond %{HTTP_HOST} ^70.XX.XX.XXX [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^s158783.gridserver.com$
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^new.domain.com$
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^beta.domain.com$
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

# URLS amigables
RewriteRule ^page/(.+)/(.+) page.php?id=$2&friendly=1 
RewriteRule ^pregunta/(.+)/(.+) pregunta.php?id=$2&friendly=1
RewriteRule ^new/(.+)/(.+) new.php?id=$2&friendly=1
RewriteRule ^user/(.+)/(.+) user.php?que=user&id=$2&friendly=1 
RewriteRule ^pages-de-cocina/$ pages.php?$1&friendly=1 [QSA]
RewriteRule ^pages/(.+)/(.+) pages.php?que=cat&f=$2&friendly=1 [QSA]

URL's that fail:

/page/the-title/4  
/user/the-name/6
anubhava
  • 761,203
  • 64
  • 569
  • 643
Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378

1 Answers1

2

Keep your rules like this:

Options -MultiViews
RewriteEngine On
RewriteBase /

RewriteRule ^posts/(.*)$ posts.php?$1&friendly=1 [L,QSA,NC]

RewriteRule ^page/[^/]+/(.*)$ page.php?id=$1&friendly=1 [L,QSA,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643