我正在尝试将所有网址重定向到index.php,因此此网址为:
domain.com/home/stats
将指向:
domain.com/index.php
代替。
但是,我不希望指向“公共”目录的URL,例如:
domain.com/public/images
重定向到index.php。
我尝试过在本网站上发现的许多不同的重写,但到目前为止还没有100%的重写。他们都刚刚将每个URL重定向到index.php,即使您正试图访问公共目录。
以下是我现在所拥有的:
RewriteRule !^/public/.*$ index.php
我对RegEx知之甚少,但我的理解是使用“!”字符的意思是“除此之外”。但显然,在这种情况下,它没有。
答案 0 :(得分:0)
您可以尝试以下内容:
RewriteBase /
RewriteRule ^(public/.*) $1 [L]
RewriteRule ^index.php$ index.php [L]
RewriteRule ^(.*) index.php
第二行是让URI保持原样。第三行是为了避免index.php陷入无限循环。第一个和第二个ReWriteRule
应在处理后立即停止([L]
)。最后一个适用于其他一切。