.htaccess中的Joomla 301重定向返回404错误

时间:2014-12-30 23:34:28

标签: apache .htaccess redirect joomla

我正在尝试向我的.htaccess文件添加301重定向,但我的网站不断返回404 error -- Article not found

我的.htaccess文件如下所示:

##
# @version $Id: htaccess.txt 13415 2009-11-03 15:53:25Z ian $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##

#####################################################
#  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On
RewriteRule ^enroll(/.*)?$ http://www.avantresources.com/store/live-seminar-tattoos-piercings-and-cross-dressing-oh-my-detail$1 [L,NC,R=302]

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

# RewriteBase /

RewriteCond %{HTTP_HOST} ^avantresources.com [nc]
RewriteRule ^(.*)$ http://www.avantresources.com/$1 [r=301,nc]


# Enable XSendFile
XSendFile On

########## Begin - Joomla! core SEF Section
#

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

Redirect 301 /index.php/Webinars/Independent-Contractor-Misclassification.html http://www.avantresources.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=82&category_id=1&option=com_virtuemart&Itemid=20
Redirect 301 /index.php/Webinars/Regulating-Employee-Use-of-Smart-Phones.html http://www.avantresources.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=65&category_id=1&option=com_virtuemart&Itemid=20
Redirect 301 /index.php/Webinars/Summer-Slaves-The-Legality-of-Unpaid-Internships.html http://www.avantresources.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=94&category_id=1&option=com_virtuemart&Itemid=20
Redirect 301 /index.php/Speakers/Speakers/Kevin-Herring-1.html http://www.avantresources.com/speakers/54-kevin-herring

RedirectMatch  ^/accounts/bwn(.*)$ http://dev.netcontentinc.net/accounts/bwn/$1

AddType video/ogg  .ogv
AddType video/mp4  .mp4
AddType video/webm .webm
SetEnvIfNoCase Request_URI .(og[gv]|mp4|m4v|webm)$ no-gzip dont-vary
Redirect http://www.avantresources.com/store/events/i-9-and-e-verify http://www.avantresources.com/store/i-9-and-e-verify-detail
Redirect 301 /index.php/store/training-products/412-mean-girls-female-to-female-bullying-in-the-workplace http://www.avantresources.com/store/training-products/408-mean-girls-female-to-female-bullying-in-the-workplace
Redirect 301 /video http://www.avantresources.com/index.php?option=com_chronocontact&chronoformname=arvid
redirect /store/events/i-9-and-e-verify http://www.avantresources.com/store/i-9-and-e-verify-detail
redirect /store/events/why-safety-should-matter-to-hr http://www.avantresources.com/store/why-safety-should-matter-to-hr-detail
redirect /store/events/correctly-handling-abandoned-wages http://www.avantresources.com/store/correctly-handling-abandoned-wages-detail
redirect /store/training-products/1554-designing-a-successful-onboarding-program http://www.avantresources.com/store/designing-a-successful-onboarding-program-detail
redirect /store/events/replacing-annual-performance-reviews http://www.avantresources.com/store/replacing-annual-performance-reviews-detail
redirect /store/events/designing-a-successful-onboarding-program http://www.avantresources.com/store/designing-a-successful-onboarding-program-detail
redirect /store/training-products/1865-why-safety-should-matter-to-hr http://www.avantresources.com/store/why-safety-should-matter-to-hr-detail
redirect /store/events/mastering-excel-pivot-tables http://www.avantresources.com/store/mastering-excel-pivot-tables-detail
redirect /store/events/1847-mastering-excel-pivot-tables http://www.avantresources.com/store/mastering-excel-pivot-tables-detail
redirect /store/training-products/1853-i-9-and-e-verify http://www.avantresources.com/store/i-9-and-e-verify-detail
redirect /store/events/1835-payroll-records-and-the-flsa http://www.avantresources.com/store/payroll-records-and-the-flsa2014-01-22-17-30-23_-detail
redirect /store/training-products/1832-payroll-records-and-the-flsa http://www.avantresources.com/store/payroll-records-and-the-flsa2014-01-22-17-30-23_-detail
redirect /store/events/13-successful-strategies-to-manage-workplace-conflict http://www.avantresources.com/store/13-successful-strategies-to-manage-workplace-conflict-detail
redirect /store/training-products/1841-13-successful-strategies-to-manage-workplace-conflict http://www.avantresources.com/store/13-successful-strategies-to-manage-workplace-conflict-detail
redirect /store/events/hipaa-omnibus-rule-compliance http://www.avantresources.com/store/hipaa-omnibus-rule-compliance-detail
redirect /store/training-products/1416-hipaa-omnibus-rule-compliance http://www.avantresources.com/store/hipaa-omnibus-rule-compliance-detail
redirect /store/events/creating-interactive-employee-evaluations http://www.avantresources.com/store/creating-interactive-employee-evaluations2014-01-07-21-34-00-detail
redirect /store/training-products/1615-creating-interactive-employee-evaluations http://www.avantresources.com/store/creating-interactive-employee-evaluations2014-01-07-21-34-00-detail
redirect /store/events/complying-with-osha-recordkeeping-requirements http://www.avantresources.com/store/complying-with-osha-recordkeeping-requirements-detail
redirect /store/training-products/1826-complying-with-osha-recordkeeping-requirements http://www.avantresources.com/store/complying-with-osha-recordkeeping-requirements-detail
redirect index.php?option=com_docman&task=cat_view&gid=291&Itemid=63 http://www.avantresources.com/index.php?option=com_docman&task=cat_view&gid=278&Itemid=63

#########################
## BELOW ISN'T WORKING ##
#########################
redirect /enroll http://www.example.com/new-page


###added 20130213 by sc to block comment spam
<Files *>
order allow,deny
allow from all
deny from 195.190.13.
deny from 94.242.237.
deny from 213.238.175.7
deny from 5.39.219.26
</Files> 

当我尝试点击/enroll时,我会收到并看到如下错误:

404 Joomla error

我认为这与Joomla的想法有关/old-page是文章的链接。但是,我的重定向不应该拦截此请求并提供正确的页面吗?

1 个答案:

答案 0 :(得分:0)

而不是这条规则:

redirect /enroll http://www.example.com/new-page

RewriteEngine On

下面添加此规则
RewriteRule ^enroll(/.*)?$ http://www.example.com/new-page$1 [L,NC,R=302]

另外,请确保在新浏览器中对此进行测试,以避免旧的301缓存。