Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Dashes In the Url Causing 404 Error

0

72 views

I'm working in PHP (5.2.14) on an Apache Server (1.3.33) with MySQL, and a problem has emerged with the pretty url's that produced by our .htaccess file. For example, www.example.com/pages/page will work, while www.example.com/page/this-other-page suddenly does not work anymore. If I type in underscores instead, the 404 goes away, but the page uri's are stored in the database with dashes, so it returns a "page not found" CMS error.

Here are the rewrite rules that put in the dashes.

RewriteRule ^([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/?$ page.php?module=$1&uri=$2 [L]
RewriteRule ^([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/?$ page.php?module=$1&uri=$2&sec_uri=$3 [L]
RewriteRule ^([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/?$ page.php?module=$1&uri=$2&sec_uri=$3&tri_uri=$4 [L]

I suspect there is some configuration rule on the server that does not like the dashes, but it's not on our server. The client is hosting elsewhere, and their server admin has not helped at all.

Or is there a php configuration rule that might fix it?

asked January 25, 2011 3:11 pm CST
posted via StackOverflow

1 Answers

0
Best answer
 

As far as I know, the characters in the square brackets aren't escaped - try using [a-zA-Z0-9_-] instead. The hyphen should be the last character otherwise the parser tries to treat it as part of a range (e.g. a-z).

answered January 25, 2011 4:07 pm CST

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Jsp error....
January 5, 2011