我有一个小网站,我已经写了一些规则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