【发布时间】:2020-11-21 01:12:33
【问题描述】:
我需要 .htaccess 重定向方面的帮助。 有很多类似的答案,但没有找到适合我的情况。
我有这个配置:
<IfModule mod_rewrite.c>
RewriteEngine On
# Rewrite to index.php if not file or directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
现在我需要重定向所有 url,但不需要重定向 'news_list'
这适用于所有重定向:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ https://www.newsite.com/$1 [R=301,L]
</IfModule>
对于例外我应该使用: RewriteRule !^news_list($|/) https://www.newsite.com/$1 [R=301,L]
这行得通 - 'news_list' 不会重定向,但问题是,'/news_list' 不起作用(因为它需要指向 'index.php?url=news_list'。
所以我需要上面所有配置的混合,但没有运气。 提前谢谢!
【问题讨论】:
标签: .htaccess exception redirect