在Joomla上使用.htaccess使用sh404sef重定向剥离url



在一个Joomla网站上工作,使用sh404sef将旧的url.html结尾更改为url/

但是我当然想在旧的。html上做一个301重定向到新的,sh404sef不这样做,我可以逐个url做,但在这种情况下这不是一个选项。

一直在尝试一切使用。htaccess,但我不能只是让它工作,不知道是否有任何其他的东西是在。htaccess或在sh404sef重写这个,需要一个解决方案。

这里是

   RewriteEngine On
########## 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!
#
# Block out any script trying to set a mosConfig value through the URL
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 /

########## 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]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*index.html HTTP/
RewriteRule ^(([^/]+/)*)index.html$ http://www.example.com/$1 [R=301,L]
########## End - Joomla! core SEF Section
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+).html$ $1/ [R=301,NC]
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1 [R=301,L]


php_flag display_errors off
php_flag register_globals off
php_value memory_limit 64M

所以为了澄清一切

It was> http://www.website.com/page.html

现在是http://www.website.com/page/

当有人点击旧的。html url时,他们会得到一个404,这会杀死访问者和seo。我尝试了htaccess中所有常用的命令来做到这一点,但它不起作用。需要建议如何解决这个问题!

类似这样——在其他规则之前——但在您第一次打开RewriteEngine

之后
RewriteCondition  %{REQUEST_FILENAME} !-f
RewriteRule (.*).html$ $1/ [R=301]

顺便说一下-你似乎有多个RewriteEngine On的实例-这可能会导致某些服务器上的服务器500错误。

我的工作是这样的:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /yourfolderjoomla/
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]

最新更新