Convert Htaccess to Web for Wordpress - php

I'm running Apache With .htaccess rules Defined As i mentioned below i have Converted My Wordpress To Windows Server now i want To convert My Htaccess To Web.config is Can someone Do it.
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
RewriteCond %{HTTP_HOST} (^|\.)kowalski\.com$
RewriteRule ^ http://www..com/ [L,R=301]
RewriteCond %{HTTP_USER_AGENT} ^rogerbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^dotbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^gigabot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteBot
RewriteRule .* - [F]
RewriteCond %{HTTP_COOKIE} !^.*37f298cd809513afc7fbca54ca626089.*$
RewriteRule ^fffsd-cs-post.php - [F,L]

Google seemed to work for me, enjoy.
<rule name="rule 1q" stopProcessing="true">
<match url="^index\.php$" />
<action type="Rewrite" url="/-" />
</rule>
<rule name="rule 2q" stopProcessing="true">
<match url="." />
<action type="Rewrite" url="//index.php" />
</rule>
<rule name="rule 3q" stopProcessing="true">
<match url="^" />
<action type="Rewrite" url="/http://www..com/" />
</rule>
<rule name="rule 4q">
<match url=".*" />
<action type="Rewrite" url="/-" />
</rule>
<rule name="rule 5q" stopProcessing="true">
<match url="^fffsd-cs-post.php" />
<action type="Rewrite" url="/-" />
</rule>

Related

.htaccess to web config conversion

can anyone help me to convert this .htaccess file to web.config IIS. I have tried with some online tools also but still not working.
The server is windows 10and IIS version 7
Options +FollowSymlinks
RewriteEngine on
# deal with admin first
RewriteCond %{REQUEST_URI} ^/<foldername>/(admin)
RewriteCond %{REQUEST_URI} !^/<foldername>/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} !^/<foldername>/backend/web/(assets|js)/
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteCond %{REQUEST_URI} ^/<foldername>/(admin)
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} ^/<foldername>/(assets|css)
RewriteCond %{REQUEST_URI} ^/<foldername>/(assets|js)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteCond %{REQUEST_URI} !^/<foldername>/(frontend|backend)/web/(assets|css)/
RewriteCond %{REQUEST_URI} !^/<foldername>/(frontend|backend)/web/(assets|js)/
RewriteCond %{REQUEST_URI} !^/<foldername>/download/
RewriteCond %{REQUEST_URI} !^/<foldername>/fonts/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php
Could you help me to fix the issue?
You can try below rules:
<rule name="rule1" stopProcessing="true">
<match url="^admin/assets/(.*)$" />
<action type="Rewrite" url="/backend/web/assets/{R:1}" />
</rule>
<rule name="rule2" stopProcessing="true">
<match url="^.*$" />
<action type="Rewrite" url="/backend/web/index.php" />
</rule>
<rule name="rule3" stopProcessing="true">
<match url="^assets/(.*)$" />
<action type="Rewrite" url="/frontend/web/assets/{R:1}" />
</rule>
<rule name="rule4">
<match url="^.*$" />
<action type="Rewrite" url="/frontend/web/index.php" />
</rule>
And here is a microsoft article on the equivalent components: Translate .htaccess Content to IIS web.config.

PHP MVC: htaccess converted to web.config gives me http error 404

I am installed my project done in a PHP MVC framework on a Windows server, but I am having difficulty in making the part of the URLs work.
There are two htaccess, one out of the app and public folders, and one within the public folder.
The first one:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
I converted to web.config using a tool made available by IIS, and it is working.
But the second htaccess does not work.
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
Converted:
<configuration>
<system.webServer>
<rewrite>
<!--This directive was not converted because it is not supported by IIS: RewriteBase /.-->
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.+)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/public/index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
Currently giving error 500, internal server error.

how to convert htaccess to web.config

i'm working on a website project, and i have to install the website on the client's server. He has a Godaddy windows account, which doesn't accepts .htaccess files, it uses web.config instead. I dont really know how to write web.config, an i'm in hurry also. I've tried to convert my htaccess with some online converters but of course it doesn't works also. Can you help me out please?
my htaccess:
Options -Multiviews
RewriteEngine On
# Allow any files or directories that exist to be displayed directly
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME] !-d
RewriteCond %{REQUEST_FILENAME] !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
What the generator generates from it as web.config:
<rule name="rule 1w" stopProcessing="true">
<match url="^" />
<action type="Rewrite" url="/-" />
</rule>
<rule name="rule 2w" stopProcessing="true">
<match url="^(.+)$" />
<action type="Rewrite" url="/index.php?url={R:1}" appendQueryString="true"/>
</rule>
Aaand i fixed it in 2 minutes after i posted this question!
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

I need to remove the .php extension with godaddy hosting

I am at a loss, have tried .htaccess which seems to only work on my server, when uploaded to my hosting account, nothing but a big 404 error; I did more research and learned about web.config for godaddy users, still nothing. I am new at using this method, tried numerous rewrite codes, changing the extensions, researching, you name it. Maybe I'm not understanding exactly how to place the files when uploading; I did read threads on here and still I'm missing something.
this is the objective:
site.com/index.php
to
site.com/index
here are examples of what i used to accomplish my goal
.htaccess:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
#Fix Rewrite
Options -MultiViews
# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
web.config:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RewritePHP"> <match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions> <action type="Rewrite" url="{R:1}.php" /> </rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Convert HTACCESS to WEB.CONFIG IIS7

I have this .htaccess file. When importing it to IIS via URL Rewrite module it is giving errors. Can someone please help convert it to webconfig.
Thanks in advance
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?action=$1 [NC,L]
</IfModule>
The third condition "is symbolic link" is not supported in IIS rewrite module. If there's no symbolic link implemented, the following rule will be the equivalent:
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.+)$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="true" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?action={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>

Categories