Welcome to WebmasterWorld Guest from 54.80.87.250
Forum Moderators: Ocean10000 & incrediBILL & phranque
I am using mod_rewrite on all queries on my site. I am trying to secure it so that anytime a url that is not found in the database it throws a 404.
The problem I am having is mod_rewrite gives me a 500 error if special characters are entered. I am only using lowercase letters, numbers and hyphens in all URLs on my site.
Here is the break down,
test/index.php
$url = $_GET['p'];
$url2 = strtolower(preg_replace('/[^a-z¦0-9¦-]/i','',$url));;
if ($url != $url2) {
echo "404";
}
else {
echo "url is fine, fetching from database...";
}
.htaccess
DirectoryIndex index.php
ErrorDocument 404 errors/404.php<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([a-z¦0-9¦-]+)$ index.php?p=$1 [L]
</IfModule>
this is the error i get in the browser if i enter test!
this works file with test or te-st
Not FoundThe requested URL /test/scratch/test! was not found on this server.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.33 Server at 127.0.0.1 Port 80
error_log
[Mon Feb 25 20:48:59 2008] [error] [client 127.0.0.1] Invalid error redirection directive: errors/404.php
how can i just have the custom 404 page displayed if the user enters any characters that should not be in the url at all?
DirectoryIndex index.php
ErrorDocument 404 [b]/er[/b]rors/404.php
#
RewriteEngine on
RewriteRule ^([b][a-z0-9\-][/b]+)$ [b]/in[/b]dex.php?p=$1 [L]
Jim