Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用.htaccess文件中的regex将带有.cfm文件的所有URL从.cfm重定向到带有查询字符串的.php_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

使用.htaccess文件中的regex将带有.cfm文件的所有URL从.cfm重定向到带有查询字符串的.php

使用.htaccess文件中的regex将带有.cfm文件的所有URL从.cfm重定向到带有查询字符串的.php,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我需要重定向所有的URL,其中ext是.cfm到.php,在同一个文件中使用相同的请求查询 示例:- 从 example.com/index.cfm?queryString=1234 到 example.com/index.php?queryString=1234 URL可能有也可能没有查询字符串 所有带有.cfm的网站页面都应重定向到.php 您可以在文档\u ROOT/.htaccess文件中使用此代码: RewriteEngine On RewriteRule ^(.+?)\.cfm$

我需要重定向所有的URL,其中ext是.cfm到.php,在同一个文件中使用相同的请求查询

示例:-

example.com/index.cfm?queryString=1234

example.com/index.php?queryString=1234

URL可能有也可能没有查询字符串


所有带有.cfm的网站页面都应重定向到.php

您可以在
文档\u ROOT/.htaccess
文件中使用此代码:

RewriteEngine On

RewriteRule ^(.+?)\.cfm$ /$1.php [L,NC]
如果需要完全重定向,请在上面添加
R
标志,如下所示:

RewriteRule ^(.+?)\.cfm$ /$1.php [L,NC,R]

完全重定向的含义是什么,我不知道,我也想使用查询字符串。查询字符串会自动转发到新的URL。你测试过了吗?完全重定向可在浏览器中更改URL。