2013-01-24 87 views
0

我已經從運行IIS7.5的Windows Server 2008 R2切換到運行Apache2的CentOS服務器,因爲我有PHP性能問題。轉換web.config網址重寫爲.htaccess

我的主站點的Web.config使用url重寫並需要轉換。自從我上次使用.htaccess文件以來已經有一段時間了。 我的web.config重寫代碼:

<rule name="IndexRewrite" stopProcessing="true"> 
     <match url="^([^/]+)/?$" /> 
     <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="index.php?p={R:1}" /> 
    </rule> 

所以,它的作用是重寫P =即使用PHP來顯示相應頁面。 那麼,究竟可以做到這一點呢?我不熟悉Apache2中的mod_rewrite。

我試圖使用SocialEngine修改其他站點的重寫規則,堅果沒有運氣。鏈接

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine On 

    # Get rid of index.php 
    RewriteCond %{REQUEST_URI} /index\.php 
    RewriteRule (.*) index.php?p= [L,QSA] 
    # Rewrite all directory-looking urls 
    RewriteCond %{REQUEST_URI} /$ 
    RewriteRule (.*) index.php?p= [L,QSA] 


</IfModule> 

例子: http://example.com?p=about 應該 http://example.com/about


這是怎麼回事,當我用IIS7.5 URL重寫之前。

任何幫助?

回答

0

我已成功將其轉換爲工作.htaccess mod_rewrite代碼。 它似乎比它容易。我不得不在Google中進行更深入的搜索,並找到了一個有效的工具。

下面是我現在使用的代碼。

RewriteEngine On 
RewriteBase/
RewriteRule ^([A-z]+)$ /index.php?p=$1 

這樣就解決了。 ;)