简体   繁体   English

SEO友好网址不起作用

[英]SEO friendly URL is not working

In my .htaccess file, a have plenty of SEO friendly links. 在我的.htaccess文件中,有很多SEO友好链接。 And now I'm trying to apply SEO friendly link to a subfolder. 现在,我正在尝试将SEO友好链接应用于子文件夹。 (these files are in "latvia" folder) (这些文件位于“ latvia”文件夹中)

Here is a content of .htaccess file: 这是.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]

It works fine if to go to /latvia. 如果转到/ latvia,效果很好。 But if to go to latvia/2017/tournaments (or any other page) for some reason it will give the same page as /latvia 但是如果由于某种原因转到latvia / 2017 / tournaments(或任何其他页面),它将显示与/ latvia相同的页面

add L to the rules eg [NC, L] to indicate that it's the last rewrite to happen, otherwise since everything starts with ^latvia all rules will fall through the last rule. 将L添加到规则中,例如[NC, L]表示这是最后一次重写,否则,由于所有内容均以^latvia开头,因此所有规则都将落在最后一条规则之内。

Code: 码:

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]

You can always tests your .htaccess using pages like eg http://htaccess.mwl.be/ 您可以始终使用http://htaccess.mwl.be/之类的页面来测试.htaccess。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM