【问题标题】:Codeigniter htaccess redirections not redirecting to desired urlCodeigniter htaccess 重定向未重定向到所需的 url
【发布时间】:2018-01-22 15:20:12
【问题描述】:

我有一个我想在其上进行 seo 的 codeigniter 网站。因此,我使用路由来处理缓慢的 url,而不是使用具有方法名称和索引的 codeigniter 默认值。 有了这个问题,三个不同的网址打开了同一个页面。

1. https://www.example.com/seo-freindly-url/
2. https://www.example.com/index.php?/controller/method/42
3. https://www.example.com/controller/method/42

但我只希望第一个 url 工作,对于其他人我想通过仅使用 htaccess 重定向重定向到 seo 友好的一个。 请帮助我。 我使用 htaccess 301 重定向来重定向我的一个网址的另一件事

Redirect 301 "/plan/index/42" https://www.example.com/services/seo

每当我打开网址时,它都会在某种程度上起作用

https://www.example.com/plan/index/42

它重定向到

https://www.example.com/services/seo?/plan/index/42 

但必须是https://www.example.com/services/seo/

谢谢。

【问题讨论】:

    标签: php apache .htaccess codeigniter redirect


    【解决方案1】:

    在我这边很难测试,但你可以试试这样的:

    .htaccess

    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^controller/method/42$ /seo-friendly-url [L]
    
    redirect 301 /plan/index/42 /services/seo
    
    RewriteRule ^(system|application|cgi-bin) - [F,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Remove index.php from all URLs
    RewriteRule .* index.php/$0 [PT,L]
    

    /应用程序/配置/配置

    // This assumes you want to remove index.php from all URLs
    $config['index_page'] = '';
    

    【讨论】:

      猜你喜欢
      • 2015-09-14
      • 2016-07-02
      • 1970-01-01
      • 2018-02-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 2015-04-15
      相关资源
      最近更新 更多