Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Wisley Aguiar

Convertendo .htaccess em web.config

Recommended Posts

Olá pessoal. Eu busquei converter este .htaccess em web.config. Segui os parametros ensinados no IIS, mas não está funcionando no meu sistema, quando rodo a url dá erro 500.

Alguém poderia verificar se está correto o meu procedimento?:

 

.htaccess:

RewriteEngine On
RewriteBase /
AddType text/x-component .htc
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

#RewriteCond %{REQUEST_URI} /gamer/?(.*)
#RewriteRule ^gamer/(.*)/(.*)/$ /gamer.php?slug=$1&action=$2 [QSA,L] 

#RewriteCond %{SCRIPT_FILENAME} !-f
#RewriteCond %{SCRIPT_FILENAME} !-d
#RewriteRule ^(.*)\/(.*)$ /$1.php?slug=$2

#RewriteRule ^gamer/(.*)/(.*)$ /gamer.php?slug=$1&action=$2 [L]
#RewriteRule ^(.*)\/(.*)$ /$1.php?slug=$2 [L]




RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(com.br|com.br/)
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]

# remove .php ONLY if requested directly
RewriteCond %{THE_REQUEST} (\.php\sHTTP/1)
RewriteRule ^(.+)\.php$ /$1 [R=301,L,QSA]

# remove trailing slash ONLY if it is not an existing folder
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# rewrite to FILENAME.php if such file does exist and is not a folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L,QSA]

RewriteCond %{HTTP_HOST} !^(www\.)?world-pirates\.com\.br [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.world-pirates\.com\.br?$
RewriteRule ^([A-Za-z0-9]*)$ /gamer.php?slug=%1&action=$1 [L]

RewriteCond %{HTTP_HOST} !^(www\.)?world-pirates\.com\.br [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.world-pirates\.com\.br?$
RewriteRule ^$ /gamer.php?slug=%1&action=$1 [L]

Este é o web.config:

 

<configuration>
	<system.webServer>
		<rewrite>
			<rules>
				<rule name="rule 1B" stopProcessing="true">
					<match url="^.*$" />
					<conditions>
						<add input="{SCRIPT_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
						<add input="{SCRIPT_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
						<add input="{HTTP_HOST}" pattern="^www..*" ignoreCase="false" negate="true" />
						<add input="{HTTP_HOST}" pattern="^$" ignoreCase="false" negate="true" />
						<add input="{HTTP_HOST}" pattern="^([^.]*).(com.br|com.br/)" ignoreCase="false" negate="false" />
					</conditions>
					<action type="Rewrite" url="http://www.%1.%2%{REQUEST_URI}" />
				</rule>
				<rule name="rule 2B" stopProcessing="true">
					<match url="^(.+)\.php$" />
					<conditions>
						<add input="{THE_REQUEST}" pattern="(\.php\sHTTP/1)" ignoreCase="false" negate="false" />
					</conditions>
					<action type="Rewrite" url="/{R:1}" appendQueryString="true" />
				</rule>
				<rule name="rule 3B" stopProcessing="true">
					<match url="^(.*)/$" />
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
					</conditions>
					<action type="Rewrite" url="/{R:1}" />
				</rule>
				<rule name="rule 4B" stopProcessing="true">
					<match url="^(.*)$" />
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
						<add input="{REQUEST_FILENAME}" pattern="\.php" matchType="IsFile" ignoreCase="false" negate="false" />
					</conditions>
					<action type="Rewrite" url="/{R:1}.php" appendQueryString="true" />
				</rule>
				<rule name="rule 5B" stopProcessing="true">
					<match url="^([A-Za-z0-9]*)$" />
					<conditions>
						<add input="{HTTP_HOST}" pattern="^(www\.)?world-pirates\.com\.br" ignoreCase="false" negate="true" />
						<add input="{HTTP_HOST}" pattern="^([^.]+)\.world-pirates\.com\.br?$" ignoreCase="false" negate="false" />
					</conditions>
					<action type="Rewrite" url="/gamer.php?slug=%1&action={R:1}" />
				</rule>
				<rule name="rule 6B" stopProcessing="true">
					<match url="^$" />
					<conditions>
						<add input="{HTTP_HOST}" pattern="^(www\.)?world-pirates\.com\.br" ignoreCase="false" negate="true" />
						<add input="{HTTP_HOST}" pattern="^([^.]+)\.world-pirates\.com\.br?$" ignoreCase="false" negate="false" />
					</conditions>
					<action type="Rewrite" url="/gamer.php?slug=%1&action={R:1}" />
				</rule>
			</rules>
		</rewrite>
	</system.webServer>
</configuration>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

vc já colocou o parâmetro?


		<httpModules>
			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
			<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
		</httpModules> 

 

outro detalhe é que o "&" comercial tem que ficar assim (&):

 

 

<rule name="NOMEDAREGRA">
<match url="^categoria/(.*)/([0-9]+)/bla-bla-bla\.html" />
<action type="Rewrite" url="suahtml.php?categoria={R:1}&id={R:2}" />
</rule>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.