我想将myapp.com/foo
重定向到myapp.com/redirect.php
/ foo是不存在的端点
我有以下.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# This is not working
RewriteRule ^foo /redirect.php [R=301,NC,L]
# Enfore SSL - This works
RewriteCond %{HTTP_HOST} ^(www\.)?myapp\.com$ [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
</IfModule>
答案 0 :(得分:0)
如果在foo之后添加$,那么一切都会改变吗?
RewriteRule ^foo$ redirect.php [R=301,L]
或使用RewriteBase
RewriteBase /
RewriteRule ^foo$ redirect.php [R=301,L]