2012-09-04 73 views
2

我有一個簡單的mod_rewrite規則,讓我重新定向是不實際的文件或目錄的index.php文件使用mod_rewrite與XAMPP和Windows 7 - 64位?

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> 

我的公關oblem是當過我傳遞任何varible的憑證例如

http://locahost/test/somethinghere/andhere 

它重定向我是

http://locahost/xampp 
+0

是您的XAMPP背景設置爲一臺主機(例如一切的http://本地主機)或您使用的虛擬主機? – zamnuts

+0

@zamnuts我認爲它使用VirtualHost,但它的自動管理,因爲所有的WordPress的和其他腳本重新編寫規則正在工作沒有問題 – Marco

+0

我不認爲我可以幫你沒有看到你的httpd.conf和你的虛擬主機配置。 – zamnuts

回答

1

解決 本地主機的默認頁我剛添加的文件夾中的.htaccess和刪除選項+ SymLinksIfOwnerMatch

RewriteBase /test/ 
+0

XAMPP Windows 7. .htaccess文件在哪裏? –

5

以下是關於如何在xampp中啓用.htaccess mod_rewrite的說明。

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. 

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