Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

php - using mod_rewrite with XAMPP and windows 7 - 64 bit?

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

  1. Open and edit C:xamppapacheconfhttpd.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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...