1
我想要做的是能夠指向username.domain.com
到index.php?url=username
。我一直在瀏覽谷歌/ StackOveflow,一直沒能找到任何有益於我的東西。.htaccess點子域到文件
最好的問候。
我想要做的是能夠指向username.domain.com
到index.php?url=username
。我一直在瀏覽谷歌/ StackOveflow,一直沒能找到任何有益於我的東西。.htaccess點子域到文件
最好的問候。
你的文檔根添加這些規則的htaccess文件:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain.com$ [NC]
RewriteCond %{REQUEST_URI} !index.php
RewriteRule^/index.php?url=%1 [L]
第一個條件可以確保請求的主機不www.domain.com或domain.com,下行匹配並對子域名進行分組,規則本身用查詢字符串url和子域(使用%1反向引用)將所有內容重寫爲/index.php
。
不起作用。我正在使用 'RewriteEngine On'' 'RewriteCond%{HTTP_HOST}!^(www \。)?titancontent.com $ [NC]' 'RewriteCond%{HTTP_HOST} ^([^。] +)\。titancontent .com $ [NC]' 'RewriteRule^/index.php?url=%1 [L]' 它說GC找不到頁面。 –
@BryanParmenter缺少一個條件來排除對'index.php'的請求。 –
仍然不起作用。 http://pastebin.com/MZ15959P –