【发布时间】:2012-08-29 15:48:56
【问题描述】:
我有一个简单的 mod_rewrite 规则,它允许我将任何不是实际文件或目录的请求重定向到 index.php 文件
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
在 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);
?>
我的开发环境是 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>
我的问题是当我将任何变量传递给脚本时
http://locahost/test/somethinghere/andhere
它将我重定向到本地主机默认页面
http://locahost/xampp
【问题讨论】:
-
是您的 xampp 上下文设置为单个主机(例如 localhost 中的所有内容)还是使用虚拟主机?
-
@zamnuts 我认为它使用了 VirtualHost 但它是自动管理的,因为所有的 wordpress 和其他脚本重写规则都可以正常工作
-
如果不查看您的 httpd.conf 和虚拟主机配置,我认为我无法为您提供帮助。
标签: php apache mod-rewrite xampp