Wordpress, joomla veya kendi yazdığınız bir php scripte .htacces dosyası ile seo url yapmak istediğinizde işin içinden çıkamayabilirsiniz.
Aslında .htaccess yerine windows sunuculada web.config dosyasını düzenleyerek kolaylıkla seo url lerinizi veya .htaccess ile yapmaya çalıştığınız diğer ayarları yapabilirsiniz. windows sunucuda .htaccess ayarlarını aşağıdaki örneklerden inceleyebilirsiniz.
Örnek .htaccess dosyası
Kod: Tümünü seç
RewriteBase /
RewriteRule ^(.*)-f([0-9]*)/(.*)-t([0-9]*)-s([0-9]*).html viewtopic.php?f=$2&t=$4&start=$5&%{QUERY_STRING} [L]
RewriteRule ^(.*)-f([0-9]*)/(.*)-t([0-9]*).html viewtopic.php?f=$2&t=$4&%{QUERY_STRING} [L]
RewriteRule ^(.*)-f([0-9]*)/index-s([0-9]*).html viewforum.php?f=$2&start=$3&%{QUERY_STRING} [L]
RewriteRule ^(.*)-f([0-9]*)/ viewforum.php?f=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-f([0-9]*) viewforum.php?f=$2&%{QUERY_STRING} [L]
Gelelim .htaccess dosyamızın yerine koyacağımız web.config dosyasına
Örnek web.config dosyası
Kod: Tümünü seç
<system.webServer>
<rewrite>
<rules>
<rule name="Extension Routes1" stopProcessing="true">
<match url="^(.*)-f([0-9]*)/(.*)-t([0-9]*)-s([0-9]*).html" ignoreCase="true" />
<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="viewtopic.php?f={R:2}&t={R:4}&start={R:5}" appendQueryString="true" />
</rule>
<rule name="Extension Routes2" stopProcessing="true">
<match url="^(.*)-f([0-9]*)/(.*)-t([0-9]*).html" ignoreCase="true" />
<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="viewtopic.php?f={R:2}&t={R:4}" appendQueryString="true" />
</rule>
<rule name="Extension Routes3" stopProcessing="true">
<match url="^(.*)-f([0-9]*)/index-s([0-9]*).html" ignoreCase="true" />
<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="viewforum.php?f={R:2}&start={R:3}" appendQueryString="true" />
</rule>
<rule name="Extension Routes4" stopProcessing="true">
<match url="^(.*)-f([0-9]*)/" ignoreCase="true" />
<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="viewforum.php?f={R:2}" appendQueryString="true" />
</rule>
<rule name="Extension Routes5" stopProcessing="true">
<match url="^(.*)-f([0-9]*)" ignoreCase="true" />
<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="viewforum.php?f={R:2}" appendQueryString="true" />
</rule>
<rule name="Extension Routes6" stopProcessing="true">
<match url="^(.*)$" ignoreCase="true" />
<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="app.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
iki kodu karşılaştırdığınızda web.config dosyasını kendi yazılımınıza göre kolaylıkla düzenleyebilirsiniz.