Error 404 Pages - Mod Rewrite

Hi.

I am currently working on building a custom CMS. I am stuck with the mod rewrite function/rule.

For the past week, I have been going through various tutorials, text & videos; but this thing doesn’t seem to work properly for me. It keeps giving me 404 Error pages; no matter what I do.

.htaccess file

<IfModule mod_rewrite.so>
	RewriteEngine On
	RewriteCond %{REQUEST_FILENAME} ! -d
	RewriteCond %{REQUEST_FILENAME} ! -f
	RewriteCond %{REQUEST_FILENAME} ! -l
	
	RewriteRule ^(.*)$	index.php?url=$1	[QSA,L]  
</IfModule>

index.php file

<?php
		
	if(isset($_GET['url']))
		echo "Action: ".$_GET['url'];
	else
		echo "Action: none";
		
?>

My base directory is
127.0.0.1/xampp/testcodes/urlmod
I saw in many tutorials that the ‘IF’ condition in the .htaccess file is not required. But if I remove it, I keep getting Error 500.
Can anyone help me out?

It is also not working for Joomla & Wordpress which I have installed locally. Getting Error 404 pages.

Sounds like mod_rewrite is either not installed, or not enabled in httpd.conf
Seeing are you’re running xampp (right?) it’s probably the latter. Find httpd.conf, and then find the line

AddModule mod_rewrite

or something to that extent. Than uncomment that line and restart Apache (or xampp, if that has a restart option – I’ve never used it myself).

MK2,

Rémon is correct: The 500 error indicates that mod_rewrite is NOT enabled.

In the typical Apache server configuration file, the mod_rewrite line is commented out:

#LoadModule rewrite_module modules/mod_rewrite.so

Merely remove the # at the start of the line and restart Apache. While you’re at it, though, also look for Options and AllowOverride (instructions are in the tutorial linked in my signature) so mod_rewrite will not only be enabled but allowed to work.

While you’re at it, ask yourself why you’d want to allow symbolic links in your mod_rewrite code AND why you don’t know enough to add a warning regarding the <IfModule> wrapper that it’s VERY ABUSIVE of the server and MUST be removed once mod_rewrite is confirmed.

Regards,

DK

I have enabled the mod_rewrite module in the xampp/apache/conf/httpd.conf file.
When i search through the httpd.conf file, the “AddModule mod_rewrite” line is absent from the file by default. When I add that line, Apache just doesn’t start up giving an invalid command error.

I went through the tutorial in your signature. Your first example is about test page (test.html and test.php). But it gave me the same problem.
I have also changed “AllowOverride None” to “AllowOverride All” as you mentioned.

I will go through it once again.

Here’s my httpd.conf file.

Guys, I found out my mistake.
Working in wrong directory!!!

Was working in /xampp/htdocs/xamp/testcodes
Now working in /xampp/htdocs/testcodes

Thanks for helping out anyways…!!