将 mod_rewrite 与 XAMPP 和 windows 7 - 64 位一起使用? [英] using mod_rewrite with XAMPP and windows 7 - 64 bit?

查看:18
本文介绍了将 mod_rewrite 与 XAMPP 和 windows 7 - 64 位一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 mod_rewrite 规则,它允许我将任何不是实际文件或目录的请求重定向到 index.php 文件

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]

在 PHP 文件中,我将这个简单的代码用于处理此导航

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);
?>

我的开发环境是 XAMPP 和 Windows 7 - 64 位httpd.conf 文件

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

推荐答案

以下是关于如何在 xampp 中启用 .htaccess mod_rewrite 的说明.

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

  1. 在文本编辑器中打开并编辑 C:\xampp\apache\conf\httpd.conf

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

找到包含

#LoadModule rewrite_module modules/mod_rewrite.so

和(取消注释)更改为

LoadModule rewrite_module modules/mod_rewrite.so

  • 查找所有出现的

  • Find all occurrences of

    AllowOverride None
    

    并更改为

    AllowOverride All
    

  • 重启 xampp

  • Restart xampp

    这样你就可以走了.

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

    这篇关于将 mod_rewrite 与 XAMPP 和 windows 7 - 64 位一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆