gpt4 book ai didi

php - 需要使用 htaccess 将 php 页面重定向到 html 吗?

转载 作者:搜寻专家 更新时间:2023-10-31 21:27:07 25 4
gpt4 key购买 nike

我已经从这个 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]

最佳答案

.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

关于php - 需要使用 htaccess 将 php 页面重定向到 html 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34433073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com