使用index.php在子文件夹重定向和多少在htaccess文件


using index.php in subfolder redirects and how many in htaccess file

域的每个位置都有子文件夹,每个位置文件夹中都有一个index.php文件。我被告知,我需要摆脱所有的链接和引用"index.php",我不确定这是如何与重定向工作。这不是我通常使用的。

  1. 哪个是正确的?

    Redirect 301 /charlottenc.html http://teamlocksmith.com/charlotte/index.php
    Redirect 301 /charlottenc.html http://teamlocksmith.com/charlotte/ 
    Redirect 301 /charlottenc.html http://teamlocksmith.com/charlotte
    
  2. 这两个都需要吗?这三个都显示为抓取错误。

    Redirect 301 /fortlauderdale/index.php http://teamlocksmith.com/fort-lauderdale/index.php
    Redirect 301 /fortlauderdale/ http://teamlocksmith.com/fort-lauderdale/index.php
    Redirect 301 /fortlauderdale http://teamlocksmith.com/fort-lauderdale/index.php
    

我有大约300左右的抓取错误移动页面,并认为这将是一个好主意,重定向到最相关的页面。我认为使用htaccess文件比使用重定向页面更容易。所以我的第一次尝试成功了,但性能受到了很大的影响。所以我检查了一下,去掉了我认为我们并不需要的重定向。所以我的问题是,如果一个htaccess文件只包含重定向是它们的数量或其他东西导致性能(加载时间)问题。

你可以这样做:

DirectorySlash On
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^fortlauderdale(/.*)?$ /fort-Lauderdale$1 [L,NC,R=301]
# remove index.php
RewriteCond %{THE_REQUEST} /index'.php [NC]
RewriteRule ^(.*?)index'.php$ /$1 [L,R=301,NC,NE]