I have switched from a Windows Server 2008 R2 running IIS7.5 to CentOS server running Apache2, as I had performance problems with PHP.
My main site’s Web.config uses url rewrite and needs to be converted. It has been a while since I last used .htaccess files.
My Web.Config rewrite code:
<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>
So what it does is Rewriting the ?p= That is used by PHP to display the appropriate page.
So, how exactly can this be done? I am not familiar with mod_rewrite in Apache2.
I tried to modify a rewrite rule from another site using SocialEngine, nut no luck.
<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>
Example of the link:
http://example.com?p=about
Should be
http://example.com/about
That’s how it was before when I used IIS7.5 Url rewrite.
Any help?
I have successfully converted it to a working .htaccess mod_rewrite code.
It seems easier than it is. I had to search deeper in Google and found a working toturial.
Here’s the code that I use now.
So this is solved. 😉