我有一個小網站,我已經寫了一些規則URL重寫htaccess的
RewriteEngine On
RewriteRule ^[!/.]*([A-Za-z0-9]+)/?$ /index.php?id=$1 [NC,L]
這會將所有我的鏈接,example.com/index.php
。雖然我希望他們重定向所有具有一個目錄example.com/dir
的URL以重定向到此鏈接example.com/index.php
,並且具有兩個目錄的URL,example.com/dir1/dir2
應該重定向到example.com/index2.php
,並且不應該重定向其餘。
添加兩個不同正則表達式的重寫規則。你需要正則表達式的幫助嗎? –
在webmasters.stackexchange.com上可能會更好? –
一些想法:http://httpd.apache.org/docs/current/rewrite/ – hakre