I don’t have much experience with web.config files but what I am trying to do is redirect all requests to index.php only add ?url=REQUESTED_PAGE
eg
if you went to domain.com/about.php?query=string
it would rewrite the url as domain.com/about/ to the user
but process the urldomain.com/index.php?url=about.php&query=string
the idea is to have nice looking user friendly urls whilst the index.php works out which page to show the user. (well am using smarty so which template to use)
EDIT: I am looking for help with web.config not .htaccsess I am restricted to the clients hosting and that isn’t apache unfortunately and the only mod I can find that may or may not work with iis7.5 is £45 which I can not get funding for 🙁
EDIT: My latest attempt is
<rules>
<rule name="page proc" stopProcessing="true">
<match url="domain.org.uk(.*?)\?(.*)" />
<action type="Redirect" url="{R:0}?url={R:1}?{R:2}" />
</rule>
</rules>
I think I am close but still not working
SOLVED :: !END RESULT!
<rewrite>
<rules>
<rule name="page proc">
<match url="(.*?)\/" />
<action type="Rewrite" url="/index.php?url={R:1}" appendQueryString="false" logRewrittenUrl="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{QUERY_STRING}" pattern="(.*?)(css|js|pdf|jpg|png|gif)" negate="true" />
</conditions>
</rule>
</rules>
</rewrite>
You’d need to create a
.htaccessfile with the following:This will pass all requests (unless it’s an existing file or directory) to your
index.phpscript, and you’ll be able to find out what the user requested in your PHP script by doing:So you may split the passed
urlparameter at the slashes and pass it off to the correct controller or whatever.The reason you don’t rewrite existing files or directories is static files like images, stylesheets, JavaScript files etc. Otherwise requests for those files that do exist would still be passed to your
index.phpscript.Also, the
QSAflag after theRewriteRuleallows you to continue using query strings in URLs if you wish for things like search form and pagination if you prefer to use$_GETparameters for those too instead of URL segments.