域路径在URL中循环重复

时间:2016-06-14 08:24:43

标签: apache .htaccess mod-rewrite url-rewriting

我一直在寻找,但找不到适合我问题的答案。

问题是我的网络正在循环中重复URL中的路径。例如:您可以访问domain.com/path/info.html,也可以访问domain.com/path/domain.com/path/domain.com/path/domain.com/path/...(这是环)... /在info.html

对于普通用户来说这不是问题,因为他总是使用正常的方式,但对于SEO来说,这是一场噩梦。

这可能与htaccess有关,但我们不知道它能给这个问题带来什么。你可以帮我们吗?非常感谢你!

我告诉你有问题的htaccess(至少是它的重写规则):

   <ifModule mod_headers.c>
  <filesMatch "\.(x?html?|php)$">
    Header set Cache-Control "private, must-revalidate"
  </filesMatch>
</ifModule>

FileETag None


# -----------------------------------------------------------------------
# Compressing output.
# -----------------------------------------------------------------------
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
    AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</Ifmodule>

<IfModule mod_headers.c>
    Header add Access-Control-Allow-Origin "*"
    ##Header set Access-Control-Allow-Origin "%{HTTP_ORIGIN}e" env=HTTP_ORIGIN
    ##Header set Access-Control-Allow-Credentials true
    Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
    ##Header add Access-Control-Allow-Headers "Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Content-MD5, X-Alt-Referer"
    Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"   
    ##Header add Access-Control-Max-Age 1728000
</IfModule>


# -----------------------------------------------------------------------
# Rewrite rules
# -----------------------------------------------------------------------
AddHandler text/html .htm
AddType text/html .htm

DirectoryIndex index.php
AddType application/x-httpd-php .php .html .xml
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api /apirest.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^/someindividualpage.htm
RewriteCond %{REQUEST_URI} !^/_upload
RewriteRule ^(.*)\.html$    index.php


RewriteCond %{HTTP_HOST} !^domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

# -----------------------------------------------------------------------
# Rewrite rules: Courses
# -----------------------------------------------------------------------
#RewriteRule ^([^/]+)/(.*?)/?$ index.php?url=$1&page=$2 [L]
#RewriteRule ^(.*)\.html$    index.php [L]

0 个答案:

没有答案