2013-01-24 89 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 

这样就解决了。 ;)