【问题标题】:How to sub directory project redirecting multiple old pages to new pages如何将多个旧页面重定向到新页面的子目录项目
【发布时间】:2020-02-14 05:33:27
【问题描述】:

我有子文件夹 opencart 网站

.php 不带 .php 的重定向

这是我需要移动的以下一些页面的示例,基本上页面文件夹中的任何内容都需要向下移动,而且旧页面总是在没有 php 的情况下重定向。

http://www.example.com/subfolder/login.php 到 http://www.example.com/subfolder/login

http://www.example.com/subfolder/register.php 到 http://www.example.com/subfolder/register

http://www.example.com/subfolder/account.php 到 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_=$1 [L,QSA]

redirect 301 /login.php http://www.example.com/subfolder/login

我会尝试上面的代码。但没有任何工作正常

【问题讨论】:

  • 你有哪个 opencart 版本?
  • opencart 3020 版本

标签: php .htaccess opencart subdirectory


【解决方案1】:

这篇文章是关于 OpenCart 1.5 或更高版本或 Opencart 2.0 或更高版本的 301 重定向。

您的 OpenCart 搜索引擎优化有问题吗?您是否尝试添加 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]

我希望一切正常。

【讨论】:

  • 为我工作很好。非常感谢亲爱的。
猜你喜欢
  • 1970-01-01
  • 2013-09-15
  • 2017-05-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-14
  • 1970-01-01
  • 2012-05-25
  • 1970-01-01
相关资源
最近更新 更多