如何子目录项目将多个旧页面重定向到新页面
How to sub directory project redirecting multiple old pages to new pages
我有子文件夹 opencart 网站
.php 不带 .php
的重定向
这是我需要移动的以下一些页面的示例,基本上 pages 文件夹中的所有内容都需要向下移动,而且旧页面总是重定向 witout php。
http://www.example.com/subfolder/login.php to
http://www.example.com/subfolder/login
http://www.example.com/subfolder/register.php to
http://www.example.com/subfolder/register
http://www.example.com/subfolder/account.php to
http://www.example.com/subfolder/account
这是我的 htaccess :
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
RewriteBase /subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_= [L,QSA]
redirect 301 /login.php http://www.example.com/subfolder/login
我会试试上面的代码。但一切正常
此 post 与 OpenCart 1.5 或 Opencart 2.0 或更高版本的 301 重定向有关。
您的 OpenCart SEO 有问题吗?您是否尝试添加 301 重定向?
您是否将 ?route= 添加到重定向和错误未找到消息的末尾?
有两种修复方法,都可以,但它仍然会更改目标 URL,您必须添加 ?是的问号!
第一个:
以下是您需要在 OpenCart .htaccess 文件中使用 301 重定向的示例:
Redirect 301 /subfolder/login.php http://www.example.com/subfolder/login?
Redirect 301 /subfolder/register.php http://www.example.com/subfolder/register?
Redirect 301 /subfolder/account.php http://www.example.com/subfolder/account?
或
Redirect 301 /subfolder/login.php http://www.example.com/subfolder/login/?
Redirect 301 /subfolder/register.php http://www.example.com/subfolder/register/?
Redirect 301 /subfolder/account.php http://www.example.com/subfolder/account/?
第二个:
只需在 .htaccess 文件中添加以下行:
Redirect 301 ^subfolder/login.php$ http://www.example.com/subfolder/login [R=301,L]
Redirect 301 ^subfolder/register.php$ http://www.example.com/subfolder/register [R=301,L]
Redirect 301 ^subfolder/account.php$ http://www.example.com/subfolder/account [R=301,L]
希望一切顺利。
我有子文件夹 opencart 网站
.php 不带 .php
的重定向这是我需要移动的以下一些页面的示例,基本上 pages 文件夹中的所有内容都需要向下移动,而且旧页面总是重定向 witout php。
http://www.example.com/subfolder/login.php to http://www.example.com/subfolder/login
http://www.example.com/subfolder/register.php to http://www.example.com/subfolder/register
http://www.example.com/subfolder/account.php to http://www.example.com/subfolder/account
这是我的 htaccess :
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
RewriteBase /subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_= [L,QSA]
redirect 301 /login.php http://www.example.com/subfolder/login
我会试试上面的代码。但一切正常
此 post 与 OpenCart 1.5 或 Opencart 2.0 或更高版本的 301 重定向有关。
您的 OpenCart SEO 有问题吗?您是否尝试添加 301 重定向?
您是否将 ?route= 添加到重定向和错误未找到消息的末尾?
有两种修复方法,都可以,但它仍然会更改目标 URL,您必须添加 ?是的问号!
第一个:
以下是您需要在 OpenCart .htaccess 文件中使用 301 重定向的示例:
Redirect 301 /subfolder/login.php http://www.example.com/subfolder/login?
Redirect 301 /subfolder/register.php http://www.example.com/subfolder/register?
Redirect 301 /subfolder/account.php http://www.example.com/subfolder/account?
或
Redirect 301 /subfolder/login.php http://www.example.com/subfolder/login/?
Redirect 301 /subfolder/register.php http://www.example.com/subfolder/register/?
Redirect 301 /subfolder/account.php http://www.example.com/subfolder/account/?
第二个:
只需在 .htaccess 文件中添加以下行:
Redirect 301 ^subfolder/login.php$ http://www.example.com/subfolder/login [R=301,L]
Redirect 301 ^subfolder/register.php$ http://www.example.com/subfolder/register [R=301,L]
Redirect 301 ^subfolder/account.php$ http://www.example.com/subfolder/account [R=301,L]
希望一切顺利。