【问题标题】:Redirection on stripped url on Joomla with sh404sef using .htaccess使用 .htaccess 在 Joomla 上使用 sh404sef 重定向剥离的 url
【发布时间】:2012-01-06 17:43:29
【问题描述】:

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

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

一直在尝试使用 .htaccess 进行所有操作,但我不能让它正常工作,不知道 .htaccess 或 sh404sef 中是否有任何其他东西覆盖了这一点,需要一个解决方案。

这里是htaccess

   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

所以要澄清一切

原来是>http://www.website.com/page.html

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

当有人访问旧的 .html 网址时,他们会得到 404,这会杀死访问者和 seo。确实尝试了 htaccess 中的所有常用命令来执行此操作,但它不起作用。需要建议如何解决这个问题!

【问题讨论】:

    标签: .htaccess mod-rewrite redirect joomla url-rewriting


    【解决方案1】:

    类似的东西 - 在其他规则之前 - 但在你第一次打开 RewriteEngine 之后

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

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

    【讨论】:

      【解决方案2】:

      对我来说是这样的:

      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]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-08
        • 2014-11-05
        • 1970-01-01
        • 1970-01-01
        • 2013-12-05
        • 1970-01-01
        相关资源
        最近更新 更多