php 将 mod_rewrite 与 XAMPP 和 windows 7 - 64 位一起使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12272731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
using mod_rewrite with XAMPP and windows 7 - 64 bit?
提问by Marco
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
我有一个简单的 mod_rewrite 规则,它允许我将任何不是实际文件或目录的请求重定向到 index.php 文件
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 文件中,我把这个简单的代码放在处理这个导航
<?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
我的开发环境是 XAMPP 和 Windows 7 - 64 位 httpd.conf 文件
<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
回答by matinict
Below are the instructions on how to enable .htaccess mod_rewrite in xampp.
以下是有关如何在 xampp 中启用 .htaccess mod_rewrite 的说明。
Open and edit C:\xampp\apache\conf\httpd.conf in a text editor
Find the line which contains
#LoadModule rewrite_module modules/mod_rewrite.soand (uncomment) change to
LoadModule rewrite_module modules/mod_rewrite.soFind all occurrences of
AllowOverride Noneand change to
AllowOverride AllRestart xampp
在文本编辑器中打开并编辑 C:\xampp\apache\conf\httpd.conf
找到包含的行
#LoadModule rewrite_module modules/mod_rewrite.so和(取消注释)更改为
LoadModule rewrite_module modules/mod_rewrite.so查找所有出现的
AllowOverride None并更改为
AllowOverride All重启xampp
That's it you should be good to go.
这样你就可以走了。
Help: http://www.leonardaustin.com/blog/technical/enable-mod_rewrite-in-xampp/
帮助:http: //www.leonardaustin.com/blog/technical/enable-mod_rewrite-in-xampp/
回答by Marco
Solved i just added the folder to the .htaccess and remove Options +SymLinksIfOwnerMatch
解决了我刚刚将文件夹添加到 .htaccess 并删除了 Options +SymLinksIfOwnerMatch
RewriteBase /test/
回答by Mohammad Hosein Zarchi
A rewrite rule can be enabled through in httpd.confor in .htaccessfile.
Instructions on how to enable .htaccess mod_rewritein wamp/xampp
Step 1:Go to the directory of installation :C:\xampp>\apache\confor C:\wamp\bin\apache\Apache2.2.11\conf
Step 2:Open httpd.confin 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 Noneand replace to AllowOverride All
Step 6:Now restart wamp/xamppserver
可以通过httpd.conf或.htaccess文件启用重写规则。
关于如何在 wamp/xampp 中启用.htaccess mod_rewrite 的说明
步骤 1:转到安装目录:C:\xampp>\apache\conf或C:\wamp\bin\apache\Apache2.2.11\conf
步骤 2:在文本编辑器中打开httpd.conf
步骤 3:找到包含的行
#LoadModule rewrite_module modules/mod_rewrite.so
步骤 4:从使模块启用的行首
第 5 步:现在将所有出现的AllowOverride None和替换为AllowOverride All
第 6 步:现在重新启动wamp/xampp服务器

