2014-12-30 64 views
1

我想添加301重定向到我的.htaccess文件,但我的網站一直返回404 error -- Article not foundJoomla 301重定向在.htaccess返回404錯誤

.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是一篇文章的鏈接。但是,我的重定向不應攔截此請求並提供正確的頁面嗎?

+0

可以顯示完整的.htaccess文件嗎? – anubhava

+0

@anubhava剛剛添加完整的.htaccess –

回答

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緩存。

+0

嗯。我仍然收到Joomla 404錯誤。 –

+0

造成錯誤的網址是:'http:// www.avantresources.com/enroll' - 我會爲該問題添加錯誤的截圖。 –

+0

剛剛用我當前的'.htaccess'編輯過這個問題 - 我相信語法是正確的。任何想法是什麼? –