我想将http://sub.domain.com/summit/重定向到http://sub.domain.com/summit/home/。谷歌搜索后,我发现很少的规则,但没有一个工作,它保持循环,并多次添加/ summit / home,下面是我最后一次尝试的原因
RewriteRule summit/(.*)$ /summit/home/$1 [R=301,NC,L]
我想将http://sub.domain.com/summit/重定向到http://sub.domain.com/summit/home/。谷歌搜索后,我发现很少的规则,但没有一个工作,它保持循环,并多次添加/ summit / home,下面是我最后一次尝试的原因
RewriteRule summit/(.*)$ /summit/home/$1 [R=301,NC,L]
以下是完整的.htaccess文件
RewriteEngine On
RewriteBase /
php_flag magic_quotes_gpc Off
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^articles/([1-9]+)(.*)$ ?id=$1&$2 [R=301,L]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^research/([1-9]+)(.*)$ ?id=$1&$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
ExpiresByType text/css "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE image/gif
AddOutputFilterByType DEFLATE image/jpeg
AddOutputFilterByType DEFLATE image/png
答案 0 :(得分:1)
您可以使用否定前瞻:
RewriteCond %{REQUEST_URI} !/summit/home [NC]
RewriteRule ^summit/(.*)$ /summit/home/$1 [R=301,NC,L]