SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2012
    Location
    India
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation 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
    Code:
    <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
    Code:
    <?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.

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,095
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    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
    Code:
    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).
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,671
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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:
    Code:
    #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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    SitePoint Member
    Join Date
    Mar 2012
    Location
    India
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    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
    Code:
    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).
    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.





    Quote Originally Posted by dklynn View Post
    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:
    Code:
    #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 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.
    httpd.zip

  5. #5
    SitePoint Member
    Join Date
    Mar 2012
    Location
    India
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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..!!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •