[Joomla and IIS] Enabling Search Engine Friendly URLs
Aug 28
Hôm nay viết 1 mẹo giúp enable SEF cho site chạy Joomla trên host Windows chạy IIS
Để dùng được SEF trên host chạy IIS thì bản thân host đó phải hỗ trợ URL rewriting. IIS 6.0 thì không hỗ trợ sẵn nên ta phải dùng 1 module của hãng thứ 3, ví dụ như ISAPI_Rewrite hoặc Ionics ISAPI Rewrite Filter. IIS7.0 đã hỗ trợ URL rewriting, việc cần làm là cài đặt Microsoft URL Rewrite Module for IIS 7.0 cho host là có thể sử dụng được.
Sau khi đã chắc chắn host đã hỗ trợ đầy đủ URL rewriting, tạo file web.config tại thư mục gốc của joomla, giống như C:\inetpub\wwwroot\<your joomla folder>, sau đó paste đoạn mã xml sau:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Security Rule" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" ignoreCase="false" /> <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" ignoreCase="false" /> <add input="{QUERY_STRING}" pattern="(\<|%3C).*script.*(\>|%3E)" /> <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" /> <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" /> </conditions> <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> <rule name="SEO Rule"> <match url="(.*)" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" /> <add input="{URL}" negate="true" pattern="^/index.php" ignoreCase="false" /> <add input="{URL}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" /> </conditions> <action type="Rewrite" url="index.php" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
Lưu lại rồi chuyển vào quản lý mục Global Configure trong administrator của joomla. Enable SEO Setting của joomla, save là xong.
Quá đơn giản phải không








