I have a .htaccess file. I have two RewriteRule's that do the same thing.

This one works perfectly, and can handle a huge query:

RewriteRule ^p/(.*)(/?)$ index.php?p=$1 [QSA,L]

This one will only handle a query up to 255 characters.

RewriteRule ^(.*)(/?)$ index.php?p=$1 [QSA,L]

How do I fix this, and make both handle a huge query?

Member Avatar for diafol

DO you have anything else in the file. Could you print out the entire .htaccess? REQUEST_FILENAME has been known to be involved with string length limitations.

I'd rather not give my entire htaccess file, but I can assure you that there are no Rewrite Conditions before it that affect these Rewrite Rules.

Member Avatar for diafol

there are no Rewrite Conditions before it that affect these Rewrite Rules

OK, sorry, am stumped. Anybody else?

By "query", are you referring to the length of the value for p in the URL?

Does the value of p, when it doesn't work correspond to the name of another physical file?

E.g. if you visit /hello, is there a file called hello.php?

Can you provide some example URLs that work and fail?

When you visit one of the URLs that fail and var_dump the value of p in index.php, what does it show?

Yes, query does refer to the value of 'p' in the url.
The 'p' value is not another file, but a string of characters where each character represents a value.

The best way for me to provide some example url's that work and don't work is like this:
http://[sitename].com/p/[256+chars] (works)
http://[sitename].com/[256+chars] (doesn't work)
Both links are the same and provide a query of 'p'.

Just for reference, there is also a 'u' query:

# if request is short url
RewriteRule ^u/(.*)(/?)$ index.php?u=$1 [QSA,L]

# if request is p query
RewriteRule ^p/(.*)(/?)$ index.php?p=$1 [QSA,L]

# If request has 6 chars, make short url query
RewriteRule ^([a-zA-Z1-9]{6})(/?)$ index.php?u=$1 [QSA,L]

# If not short url query, make p query
RewriteRule ^(.*)(/?)$ index.php?p=$1 [QSA,L]

For the non-working url, it gives a 403 Forbidden error which is the same thing that happens when I do a var_dump of the value.

I understand that p is a character string. I was asking whether co-incidentally there was another, un-related file or directory for that matter, with the same name as the character string?

The 403 error hints at a permission problem. Most likely not with the index.php file, otherwise none of the other URLs would work either, but worth checking either way. Are the permissions for index.php 644?

If/when you're able to view index.php, if you var_dump the $_GET and $_SERVER global arrays, the output could be helpful to show how the file is being routed and what's being passed through the query string.

Other than that, I'm out of ideas without tinkering with it myself - sorry.

The permissions for index.php are 644.
When I dump the $_GET and $_SERVER global variables, what I find is that the 403.shtml error page is in the 'p' variable. So it's basically making the url this:
http://[sitename].com/index.php?p=403.shtml

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.