[英]How to redirect everything but an specific path on a htaccess file?
I'm trying to create an htaccess
file so that everything gets redirected to the root of the site except for an specific path /api/date
. 我正在尝试创建一个htaccess
文件,以便除了特定路径/api/date
之外,所有内容都会重定向到站点的根目录。
I have this: 我有这个:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've made some research on javascript regex and it seems that it is not possible to exclude words. 我对javascript正则表达式做了一些研究,似乎不可能排除单词。 So it is possible to do this here? 所以这可以做到这一点吗? How? 怎么样?
Thanks! 谢谢!
Try with below we are excluding /api/date
and passing everything apart from that. 尝试下面我们排除/api/date
并传递除此之外的所有内容。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!(\/api\/date)$).+$ /index.php [L]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.