【问题标题】:Need to redirect php page to html using htaccess?需要使用 htaccess 将 php 页面重定向到 html 吗?
【发布时间】:2016-03-29 17:38:00
【问题描述】:

我已经从这个 url Htacess Url 阅读了 htacess 条件

但是在htacess中解决条件时无法理解如何解决问题。

我的主要问题是如何将所有 php 页面更改为 html 格式,在任何地方单击 PHP 链接然后打开

就像示例:这个 php url 可以在任何地方打开重定向到 html 页面我在 htacess 中设置的条件 PHP 网址

http://www.localhost/efundoo.com/products.php?product=Touch-Screen-Digitizer-For-Videocon-A10

然后换成

http://www.localhost/efundoo/public_html/products/lcd-display-for-samsung-galaxy-star-pro-gt-s7262.html

我的htacess情况如下

1) 运行良好

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?user=$1&type=$2  [NC,QSA]

2) 但是当我尝试这种情况时,页面没有打开

RewriteCond %{THE_REQUEST} \s/+.+?\.php\?user=([^\s&]+)&type=([^\s&]+)\s [NC]
RewriteRule . %1/%2.html? [R=301,L]
RewriteRule ^([^/]+)/([^./]+)/.html$ page.php?user=$1&type=$2 [NC,L,QSA]

【问题讨论】:

  • 页面打不开是什么意思?您收到 404 错误吗?请进一步解释,您的问题目前还不清楚
  • @Starkeen 如何使用 htacess 将 php 页面重定向到 html 页面如果 URL 来自网站和 blogspot 的任何地方

标签: php .htaccess codeigniter


【解决方案1】:

.htaccess 试试这个,

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

.htaccess 文件:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

.html.php

RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L]

.php.html

RewriteCond %{THE_REQUEST} \ /(.+)\.php
RewriteRule ^ /%1.html [L,R=301]

config.php 文件:

$config['index_page'] = ''; //specify your html file

【讨论】:

  • 是的项目在 CI 中。我在博客中发布了一些 php url,现在我的网站完全基于 html。如何使用 htacess 将这些 php URL 更改为 html 页面
  • 我看到这个但无法解决 Html 和 PHP 页面都是打开的如果用户单击 php 文件然后打开 HTML 页面,我希望仅在站点中打开一个页面 html另一个明智的 html 会自动打开 products.php?product=Full-Body-Panel-Nokia-1208-Mobile-Phone-Housing-Fascia-Faceplate
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-05-02
  • 1970-01-01
  • 2015-10-22
  • 2010-10-07
  • 2012-09-09
  • 1970-01-01
  • 2014-05-30
相关资源
最近更新 更多