I'm definitely not fond of the RewriteBase directive as that generally causes more problems than it resolves but your first three cases are good.

RewriteRule ^([^\\.\\?/]+)?$ /pagina.php?seo=$1 [L]

Here you've begun the character range definition by escaping the dot character (which is NOT required in a character range definition) then by escaping a ?. Unfortunately (and the reason it's not working for you), the ? is a reserved character (http://www.ietf.org/rfc/rfc2396.txt) which cannot be within a {REQUEST_URI} string (you may be able to encode it but I'd have to check the link above to verify that) because it's the demarcation character defining the end of the {REQUEST_URI} string and the start of the {QUERY_STRING}. Of course, if you need to access the query string in mod_rewrite, you must do so with a RewriteCond statement.

So, other than not understanding the allowed content of URIs, I'd say that you've done very well.

Regards,

DK

monchyrcg
—
2013-04-23T10:15:00Z —
#3

Thanks dklynn,

dklynn said:

So, other than not understanding the allowed content of URIs, I'd say that you've done very well.

I understand and I change. My case is so strange because if I change the first rule for this:

I feel like there must be more to this htaccess than what we're seeing, because as is, it looks like it should work correctly.

My case is so strange because if I change the first rule for this:

RewriteRule ^Prensa$ /prensa.php?seo=prensa [L]

If I change prensa for Prensa all is right, why?

Does your URL in the address bar have a capital P?

monchyrcg
—
2013-04-23T15:40:43Z —
#5

I'm doing a cms and I can change de url in the admin so I can put any word in the url. I dont understand what is the problem.

dklynn
—
2013-04-25T02:11:02Z —
#6

monchy,

Jeff simply didn't read the character definition in your code correctly. Saying that, I'm sure that he does know that RewriteRules cannot examine the query string AND that the question mark is a reserved character (which should only be in a URL to separate the URI from the query string).

http://www.ietf.org/rfc/rfc2396.txt said:

2.2. Reserved Characters

Many URI include components consisting of or delimited by, certain special characters. These characters are called "reserved", since their usage within the URI component is limited to their reserved purpose. If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI.

reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","

The "reserved" syntax class above refers to those characters that are allowed within a URI, but which may not be allowed within a particular component of the generic URI syntax; they are used as delimiters of the components described in Section 3.

It makes no matter whether you want to match the P or p so long as you are consistent. If you want to match both, use

RewriteRule ^P|prensa$ /prensa.php?seo=prensa [L]

With the OR bar between the P and p, the regex will match both Prensa and prensa (if the only content of the URI string).

Regards,

DK

Jeff_Mott
—
2013-04-25T02:30:45Z —
#7

dklynn said:

Jeff simply didn't read the character definition in your code correctly. Saying that, I'm sure that he does know that RewriteRules cannot examine the query string AND that the question mark is a reserved character (which should only be in a URL to separate the URI from the query string).

Actually I read the character definition just fine. Matching on non-question mark characters isn't causing any issues. It may be unnecessary, but it's not problematic.

Furthermore, the OP's issue isn't related to the forth rewrite rule, but the first. As the OP described, prensa is supposed to rewrite to /prensa.php?seo=prensa, but instead it's rewriting to just /prensa.php. I reiterate that I don't see anything in this htaccess that explains this behavior, nor do I see anything that explains why using a capital "P" in the URL would make it work. And so I still believe that there must be more to this htaccess than what we've seen.

monchyrcg
—
2013-04-25T08:03:25Z —
#8

Jeff_Mott said:

I reiterate that I don't see anything in this htaccess that explains this behavior, nor do I see anything that explains why using a capital "P" in the URL would make it work. And so I still believe that there must be more to this htaccess than what we've seen.

I promise that I worte all the .htaccess. About capital letter is so strange but work.

Don't work, when I try to access, return and error 500 internal server error. I use phpinfo() to know if the module mod_expires.c and I think that yes Thanks.

I dont know why but the error appears when I write anything in the if sentence

<IfModule mod_expires.c> # Enable expirations.

<filesmatch ".(jpg|JPG|gif|GIF|png|css|ico|js)$">

</filesmatch></IfModule>

If I put this I have no errors.

dklynn
—
2013-04-30T04:55:24Z —
#10

monchy,

[standard rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> ... </IfModule> wrapper is the same thing in the webmaster world. DON'T BE AN IDIOT! If you don't know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache's resources (and should NEVER be allowed on a shared server).[/indent][/standard rant #4]

Okay, that's NOT to call you an idiot, it's simply to remind you in the clearest terms possible that any webmaster would only run ONE server test, not repeat server tests multiple times for EVERY request!

You also need to learn which characters are considered metacharacters with a character range definition as it seems that you've gone "escape crazy" by escaping every character (none of which needs escaped except the ? which should not be there in the first place).

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

Regards,

DK

Jeff_Mott
—
2013-04-30T05:41:46Z —
#11

dklynn said:

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

Obligatory note:

Unfortunately anyone who learns from this tutorial will have to unlearn some incorrect information later on. I strongly recommend that anyone who's interested in this topic go straight to the definitive source for the most complete, authoritative, and correct information.

dklynn
—
2013-05-04T13:33:16Z —
#12

Jeff,

Sorry, I'd have to give the same advice to others about your insistence on using (.*) inappropriately (among other things you've come up with).

As for going straight to Apache.org, I agree. However, their documentation is too "geeky" for most so my tutorial was written to make life easier for SitePoint members ... and has received high praise from everyone (other than you - your comment is the first of its nature in the 5+ years it's been online).

Members,

Take all advice here with a grain of salt, i.e., consider the source.

Regards,

DK

Jeff_Mott
—
2013-05-04T17:52:13Z —
#13

dklynn said:

Sorry, I'd have to give the same advice to others about your insistence on using (.*) inappropriately (among other things you've come up with).

My "insistence" on using .* comes straight from the Apache documentation. They use it in the same way I do.

dklynn said:

As for going straight to Apache.org, I agree. However, their documentation is too "geeky" for most so my tutorial was written to make life easier for SitePoint members

Unfortunately your tutorial, in a number of places, contradicts the documentation, and it contradicts observable behavior in Apache.

ScallioXTX
—
2013-05-04T18:29:41Z —
#14

/x.php exists, and a RewriteRule to from /x to /x.php doesn't work. Hmm, that rings a bell.

DK, we've seen this bugger before quite a few times, you should recognize the smell of this stinky old friend by now.