7

i have a simple mod_rewrite rule which allow me to re-direct any requests that are not actual files or directories to the index.php file

    Options +SymLinksIfOwnerMatch 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

in PHP file i put this simple code to handle this navigation

<?php
$navString = $_SERVER['REQUEST_URI']; // Returns "/Mod_rewrite/edit/1/"
$parts = explode('/', $navString); // Break into an array
// Lets look at the array of items we have:
print_r($parts);
?>

my development environment is XAMPP and Windows 7 - 64 bit httpd.conf file

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>

<Directory "C:/xampp/cgi-bin">
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
</Directory>

my problem is when ever i pass any varible to the scrip for example

http://locahost/test/somethinghere/andhere

it redirect me to the local host default page which is

http://locahost/xampp
4
  • is your xampp context set up as a single host (e.g. everything in localhost) or are you using virtual hosts?
    – zamnuts
    Sep 5, 2012 at 0:17
  • @zamnuts i think its using VirtualHost but its auto manage because all of wordpress and other scripts re-write rules are working with no problem
    – Marco
    Sep 5, 2012 at 0:21
  • i don't think i can help you without seeing your httpd.conf and your virtual host configuration.
    – zamnuts
    Sep 5, 2012 at 0:29
  • check this link only4ututorials.blogspot.com/2017/04/…
    – Dexter
    Apr 22, 2017 at 11:26

3 Answers 3

16

Below are the instructions on how to enable .htaccess mod_rewrite in xampp.

  1. Open and edit C:\xampp\apache\conf\httpd.conf in a text editor

  2. Find the line which contains

    #LoadModule rewrite_module modules/mod_rewrite.so
    

    and (uncomment) change to

    LoadModule rewrite_module modules/mod_rewrite.so
    
  3. Find all occurrences of

    AllowOverride None
    

    and change to

    AllowOverride All
    
  4. Restart xampp

That’s it you should be good to go.

Help: http://www.leonardaustin.com/blog/technical/enable-mod_rewrite-in-xampp/

4

Solved i just added the folder to the .htaccess and remove Options +SymLinksIfOwnerMatch

RewriteBase /test/
2
  • XAMPP Windows 7. Where is the .htaccess file?
    – Mr. B
    Sep 24, 2015 at 5:28
  • Tried so many, much more complex variations, but actually, this was the answer for me as well. Thank you.
    – MRadev
    Apr 7, 2021 at 17:08
2

A rewrite rule can be enabled through in httpd.conf or in .htaccess file.
Instructions on how to enable .htaccess mod_rewrite in wamp/xampp

Step 1: Go to the directory of installation :
C:\xampp>\apache\conf or C:\wamp\bin\apache\Apache2.2.11\conf
Step 2: Open httpd.conf in a text editor
Step 3: Find the line which contains #LoadModule rewrite_module modules/mod_rewrite.so
Step 4: Remove (#) from start of line to make module enable
Step 5: Now Change all occurrences of AllowOverride None and replace to AllowOverride All
Step 6: Now restart wamp/xampp server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.