当用户请求http://www.hostname.com/first/api/getlink
时,我必须重定向到http://www.hostname.com/first/api.php?type=link
所以我试着跟着
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www'.hostname'.com'/first$
RewriteBase /
RewriteRule ^api/getlink$ '/api.php?type=link [L]
在.htaccess
文件中,放在first/
文件夹中。我无法得到正确的重定向。但是我得到了404 error
。有谁能指点我一下吗?
您可以在/first
目录下的一个.htaccess文件中尝试:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /first
RewriteCond %{REQUEST_URI} !api'.php [NC]
RewriteRule ^api/getlink /first/api.php?type=link [NC,L]
对于永久重定向,将[NC,L]替换为[R=301,NC,L]