0

这个区域不是我最强的区域。但是感觉我有一个大概的了解。

好的,所以我的问题是这个。我有一家我工作的公司,出于某种原因,这些可以访问:

http://www.pets4you.com/cats/(错了,应该不能和没有文件夹叫猫) http://www.pets4you.com/cats.html(正确的网址)

变得更好:pets4you.com/images/classifieds/ad_8e286189f9c4e622ea12ebdcdd10b646(嗯?)pets4you.com/images/classifieds/ad_8e286189f9c4e622ea12ebdcdd10b646.jpg

(无法制作 URL,我猜这里有 2 个链接限制)

我的托管公司告诉我这是:

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

我告诉他们他们错了。那是一个痕迹,并且评论它不会改变任何东西。

任何方式,我的代码(是的,很多东西,告诉我的老板!):

Options +FollowSymLinks
Options -Indexes

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

<IfModule mod_rewrite.c>
   RewriteCond %{HTTPS} !=on
   RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
   RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    RewriteCond %{REQUEST_URI} /+[^\.]+$
    RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>

RewriteRule ^(.*\.(css|js))$ min/index.php?f=$1&debug=0 [L]
RewriteRule ^(.*)index.php$ http://www.pets4you.com/$1 [R=301,L]

# BEGIN COMPRESSION AND CACHING
<IfModule mod_deflate.c>
    # Enable compression
    # AddOutputFilterByType DEFLATE text/css text/javascript application/x-javascript text/html text/plain text/xml image/x-icon
    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

    <IfModule mod_setenvif.c>
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    </IfModule>
    <IfModule mod_headers.c>
        # Make sure proxies deliver correct content
        Header append Vary User-Agent env=!dont-vary
        # Ensure proxies deliver compressed content correctly
        Header append Vary Accept-Encoding
    </IfModule>
</IfModule>
<IfModule mod_headers.c>
    # No ETags, No Pragma
    Header unset Pragma
    Header unset ETag
    # Default cache time to 1 year (31536000 sec)
    Header set Cache-Control "max-age=31536000, public, must-revalidate"
</IfModule>

# No ETags
FileETag none
# CACHE SETTINGS (mod_expires)

<IfModule mod_expires.c>
    # Turn on Expires
    # set default to "access plus 1 year"
    ExpiresDefault A31536000
    ExpiresActive On
    # html - "modification plus 1 hour"
    ExpiresByType text/html M3600
    # css and JavaScript - "modification plus 6 weeks"
    ExpiresByType text/css M3628800
    ExpiresByType text/javascript M3628800
    ExpiresByType application/x-javascript M3628800
</IfModule>

# No cache for php-files
<FilesMatch "\.(php)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    </IfModule>
    <IfModule mod_headers.c>
        Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
    </IfModule>
</FilesMatch> 
<IfModule mod_php5.c>
    #php_value output_handler ob_gzhandler
    php_flag display_errors Off
    php_flag log_errors On
    php_value upload_max_filesize 500M
    php_value post_max_size 500M
    php_value memory_limit 1000M
    php_flag zlib.output_compression on
    php_value zlib.output_compression_level 2
    php_flag magic_quotes_gpc Off
    php_flag magic_quotes_runtime Off
    php_flag zend.ze1_compatibility_mode Off
    php_value mbstring.func_overload 0
    php_flag suhosin.session.encrypt Off
    php_value session.auto_start 0
    php_value session.gc_maxlifetime 54000
    php_value session.gc_divisor 500
    php_value session.gc_probability 1
    php_value mysql.connect_timeout 1000
    php_value mysql.allow_persistent Off
</IfModule>
##############
# ERROR PAGES#
##############
ErrorDocument 401 /errors.php?code=401
ErrorDocument 500 /errors.php?code=500
ErrorDocument 403 /errors.php?code=403
ErrorDocument 400 /errors.php?code=400
ErrorDocument 404 /errors.php?code=404
######################
# BREED DESCRIPTIONS #
######################
RewriteRule ^dog_breed_description/teapoodle/?$ http://www.pets4you.com/dog_breed_description/poodle/ [R=301,L]
RewriteRule ^dog_breed_description/toypoodle/?$ http://www.pets4you.com/dog_breed_description/poodle/ [R=301,L]

RewriteRule ^dog_breed_description/([^/]+) descriptions.php?page=$1 [NC]
RewriteRule ^cat_breed_description/([^/]+) descriptions.php?page=$1 [NC]
############
# CALENDAR #
############
#RewriteRule ^submitevent.html calendar.php?action=submitEvent [NC]
#RewriteRule ^calendar/([^/]+)/([^/]+)/([^/]+)/([^/]+) errors.php?code=404 [NC]
#RewriteRule ^calendar/([^/]+)/([^/]+)/([^/]+) errors.php?code=404 [NC]
#RewriteRule ^calendar/([^/]+)/([^/]+) calendar.php?year=$1&month=$2 [NC]
#RewriteRule ^calendar/([^/]+) calendar.php?year=$1 [NC]
#RewriteRule ^calendar/ calendar.php [NC]
#################
# PET DIRECTORY #
#################
RewriteRule ^petsupplies/dogs/(.*).html/?$ directory.php?type=dog&page=$1 [QSA,L]
RewriteRule ^petsupplies/cats/(.*).html/?$ directory.php?type=cat&page=$1 [QSA,L]
RewriteRule ^petsupplies/(.*).html/?$ directory.php?page=$1 [QSA,L]
RewriteRule ^petsupplies/search.php?$ directory.php?page=search [QSA,L]
RewriteRule ^petsupplies/?$ http://www.pets4you.com/petsupplies.html [R=301,L]
###############
# PET GALLERY #
###############
RewriteRule ^gallery/([^/]+) gallery.php?breed=$1 [QSA,L]
RewriteRule ^gallery/?$ gallery.php [QSA,L]
RewriteRule ^gallery/index.html?$ gallery.php [R=301,L]
############
# ARTICLES #
############
RewriteRule ^petarticles/([^/]+) articles.php?action=a&id=$1 [NC]
RewriteRule ^petarticles/?$ http://www.pets4you.com/petarticles.html [R=301,L]
RewriteRule ^petarticles?$ http://www.pets4you.com/petarticles.html [R=301,L]
RewriteRule ^petarticles.html/?$ articles.php [L]
RewriteRule ^articles_search.php/?$ articles.php [QSA,L]
################
# LOST & FOUND #
################
RewriteRule ^lost_found.html/?$ lost_found.php [QSA,NC,L]
########
# DOGS #
########
RewriteRule ^studservice.html?$ http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^puppiesforsale/([^/]+) http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^dogs/([^/]+) http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^dogs/ http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^dogs.html?$ dogs.php?start=0 [QSA,L]
RewriteRule ^dogs1/?$ dogs.php?start=1 [QSA,L]
RewriteRule ^dogs2/?$ dogs.php?start=2 [QSA,L]

RewriteRule ^cats/ http://www.pets4you.com/cats.html [R=301,L]
RewriteRule ^cats.html/?$ cats.php [L]

RewriteRule ^puppiesforsale.html?$ http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^teapoodle.html?$ http://www.pets4you.com/poodle.html [R=301,L]
RewriteRule ^toypoodle.html?$ http://www.pets4you.com/poodle.html [R=301,L]
#############
# BREEDERS #
############
#RewriteRule ^dogbreeders/([^/]+) dog_breeders.php?breed=$1 [NC]
#RewriteRule ^dogbreeders/?$ http://www.pets4you.com/dog_breeders.html [R=301,L]
#RewriteRule ^dogbreeders.html/?$ dog_breeders.php [L]

#RewriteRule ^catbreeders/([^/]+) cat_breeders.php?breed=$1 [NC]
#RewriteRule ^catbreeders/?$ http://www.pets4you.com/cat_breeders.html [R=301,L]
#RewriteRule ^catbreeders.html/?$ cat_breeders.php [L]
################
# STATE PET ADS #
################
RewriteRule ^localpetads/(.*).html?start=([0-9])/?$ http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^localpetads/(.*).html/?$ http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^localpetads.html?$ http://www.pets4you.com/localpetads/ [R=301,L]
RewriteRule ^localpetads/([^/]+)/([^/]+) http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^localpetads/([^/]+) http://www.pets4you.com/dogs.html [R=301,L]
RewriteRule ^localpetads/ http://www.pets4you.com/dogs.html [R=301,L]
###########
# GENERAL #
###########
RewriteRule ^sitemap.html?$ sitemap.php?start=1 [QSA,L]
RewriteRule ^sitemap2/?$ sitemap.php?start=2 [QSA,L]
RewriteRule ^sitemap3/?$ sitemap.php?start=3 [QSA,L]
RewriteRule ^sitemap4/?$ sitemap.php?start=4 [QSA,L]

RewriteRule ^terms.html/?$ terms.html [L]
RewriteRule ^google97ce2a2538777af1.html/?$ google97ce2a2538777af1.htm [L]
RewriteRule ^googlef7b2dff2a5d7b41b.html/?$ googlef7b2dff2a5d7b41b.htm [L]
RewriteRule ^dogvideos/ videos.php [NC]
RewriteRule ^topdogs/ breedratings.php [NC]
RewriteRule ^(.*).html/?$ pets4you.php?page=$1 [QSA,L]

此外,有时当我输入“www.pets4you.com”时,它会指向 https (?) 其他让我一无所知的东西。

不是我最擅长的领域,.htaccess。有什么不对的告诉我。所有重定向工作正常。只是让我难以置信其他事情是由什么引起的。

谢谢!

4

2 回答 2

0

哦,我的,真是一团糟,肖恩。如果不正确了解服务器的内部结构(即主配置文件 (httpd-xxx.conf)),就无法准确说明发生了什么。

我发现的是:

  1. 猫 URL 问题。负责的指令是:

    RewriteRule ^cats/ http://www.pets4you.com/cats.html [R=301,L]
    RewriteRule ^cats.html/?$ cats.php [L]
    
  2. 至于使用和不使用适当文件扩展名的图像:这听起来像是mod_spelling加载到 Apache 中(您必须与您的主机商核实)。

于 2013-01-07T22:21:54.213 回答
0

好的,所以我能真正解决这个问题的唯一方法就是这样做。

我没有使用cats.php,而是将文件重命名为catspage.php。由于某种原因,使用与请求相同的名称会导致奇怪的事情发生。cat.html 指向cats.php,但cats/ 能够被拉起并调用cats.php。现在回想起来,我之前不得不和另一个客户处理过这个问题。

重命名文件后,这些 URL 停止工作,这是我想要的。然而,图像是我们的服务器。我们与他们合作的每一个网站都这样做。

再次感谢大家。

于 2013-01-08T19:42:54.070 回答