【问题标题】:.htaccess redirect URL and remove .php.htaccess 重定向 URL 并删除 .php
【发布时间】:2015-10-28 16:48:15
【问题描述】:

我当前的 .htaccess 文件是这样的 它从 url 中隐藏了 .php。

RewriteEngine on
RewriteBase    /
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

现在我想重定向我的网站以同时删除 www 即我想重定向 http://www.thefutureshop.com.pk/index.php

http://thefutureshop.com.pk

我的网站是使用 codeigniter 构建的。

【问题讨论】:

    标签: php apache .htaccess codeigniter redirect


    【解决方案1】:

    你可以使用:

    RewriteEngine on
    RewriteBase    /
    RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [NE,L,R=301]
    RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    【讨论】:

      【解决方案2】:

      试试这个

      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php/$1 [L]
      

      替换:

      $config['index_page'] = "index.php"
      to
      $config['index_page'] = ""
      

      更多信息请阅读http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-02
        • 1970-01-01
        • 1970-01-01
        • 2014-01-03
        • 2019-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多