繁体   English   中英

将所有URL重写为index.php,除了'/ Serene / Assets /'

[英]Rewrite all URL to index.php except from '/Serene/Assets/'

所以我目前在我的.htaccess中将我的所有URL重定向到index.php:

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

但是,我需要http://localhost/Portfolio/Serene/Assets/css/style.css等网址不重定向,但我不确定如何?

我真的很感激任何帮助,

干杯。

编辑:或者,我可以告诉htaccess不重定向任何.js,.css,图像文件等,但再次,我不太确定如何做到这一点? 谢谢!

EDIT2:我还可以将以.php或路径(例如/ Portfolio /)结尾的任何内容重定向到index.php,我觉得这可能更容易。

EDIT3:成功,最终代码:

RewriteEngine on

RewriteCond %{DOCUMENT_ROOT} !-f
RewriteRule !\.(js|ico|gif|jpg|png|css|html|swf|flv|xml)$ index.php [QSA,L]

这是另一种方法:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

图片,robots.txt不会被重写为index.php。 只需添加您的目录/文件。

希望有所帮助!

这将把对服务器上不存在的任何文件的请求重写为index.php:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* index.php [L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM