我想要实现的目标
prod.com 将立即移至 prod.com/cms
当我做 Redirect permanent / /cms
我得到了很多/cmscmscmscmscms 等。有什么想法吗?
我的虚拟主机
<VirtualHost *:443>
ServerName prod.com
DocumentRoot /home/www/sites/prod/html/development
<Directory /home/www/sites/prod/html/development>
AllowOverride All
</Directory>
SSLEngine on
SSLCACertificateFile /etc/pki/tls/certs/gd_bundle.crt
SSLCertificateFile /etc/pki/tls/certs/prod.crt
SSLCertificateKeyFile /etc/pki/tls/private/prod.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
我的.htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/API [NC]
RewriteRule ^(.*)$ /Application/API/api.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)$ /Application/controller.php [L]
DirectoryIndex /Application/controller.php
答案1
出现重定向循环的原因是,Redirect / /cms
匹配以 / 开头的任何路径,并将旧路径附加到新路径上。你真正想要的是:
RedirectMatch ^\/$ /cms
这仅匹配 /