繁体   English   中英

如何在htaccess文件上重定向除特定路径之外的所有内容?

[英]How to redirect everything but an specific path on a htaccess file?

我正在尝试创建一个htaccess文件,以便除了特定路径/api/date之外,所有内容都会重定向到站点的根目录。

我有这个:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我对javascript正则表达式做了一些研究,似乎不可能排除单词。 所以这可以做到这一点吗? 怎么样?

谢谢!

尝试下面我们排除/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.

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