在我的.htaccess文件中,有很多SEO友好链接。现在我正在尝试将SEO友好链接应用于子文件夹。 (这些文件位于“latvia”文件夹中)
以下是.htaccess文件的内容:
RewriteEngine on
ErrorDocument 404 /404.php
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# DO NOT REMOVE THIS LINE AND THE LINES ABOVE SSL_REDIRECT:SSL_REDIRECT
RewriteRule ^latvia/2017/tournaments latvia/2017-lv-calendar.php [NC]
RewriteRule ^latvia/adults/tournaments latvia/lvt_adults.php [NC]
RewriteRule ^latvia/juniors/tournaments latvia/lvt_juniors.php [NC]
RewriteRule ^latvia/federation latvia/lv-federation.php [NC]
RewriteRule ^latvia/juniors/rankings latvia/lvj-rankings.php [NC]
RewriteRule ^latvia/adults/rankings latvia/lva-rankings.php [NC]
RewriteRule ^latvia/rankings latvia/lv-rankings.php [NC]
RewriteRule ^latvia latvia/index.php [NC]
如果去/拉脱维亚,它可以正常工作。但是如果由于某种原因去拉脱维亚/ 2017 /锦标赛(或任何其他页面),它将提供与拉脱维亚相同的页面
答案 0 :(得分:0)
将L添加到规则中,例如[NC, L]
表示它是最后一次重写,否则因为所有内容都以^latvia
开头,所有规则都会通过最后一条规则。
代码:
RewriteRule ^latvia/2017/tournaments latvia/2017-lv-calendar.php [NC,L]
RewriteRule ^latvia/adults/tournaments latvia/lvt_adults.php [NC,L]
RewriteRule ^latvia/juniors/tournaments latvia/lvt_juniors.php [NC,L]
RewriteRule ^latvia/federation latvia/lv-federation.php [NC,L]
RewriteRule ^latvia/juniors/rankings latvia/lvj-rankings.php [NC,L]
RewriteRule ^latvia/adults/rankings latvia/lva-rankings.php [NC,L]
RewriteRule ^latvia/rankings latvia/lv-rankings.php [NC,L]
RewriteRule ^latvia latvia/index.php [NC,L]
您可以随时使用以下网页测试您的.htaccess http://htaccess.mwl.be/