[英]Htaccess: Redirect only files in public directory
I currently have a .htaccess
file that redirects[L] all requests to a router.php
.我目前有一个.htaccess
文件,该文件将 [L] 所有请求重定向到router.php
。
How can I make it redirect only URLS not heading to the public
directory我怎样才能让它只重定向不指向public
目录的 URL
That is, example.com/hello
will redirect to router.php
也就是说, example.com/hello
/hello 会重定向到router.php
But example.com/public/app.css
and example.com/public
should not be redirected at all.但是example.com/public/app.css
和example.com/public
根本不应该被重定向。
This is my .htaccess file:这是我的 .htaccess 文件:
RewriteRule ^(.*)$ router.php [QSA,L]
You could write a condition to only rewrite when it doesn't have a public
after the URI like so:您可以编写一个条件以仅在 URI 之后没有public
的情况下重写,如下所示:
RewriteCond %{REQUEST_URI} !^/public
RewriteRule ^(.*)$ router.php [QSA,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.