Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.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
Php .htaccess URL重写访问_Php_.htaccess - Fatal编程技术网

Php .htaccess URL重写访问

Php .htaccess URL重写访问,php,.htaccess,Php,.htaccess,我需要一些帮助。这是原始链接 http://tester.local/adm/index_pub.php?ch=feondi-event 我希望它是这样的 http://tester.local/feondi_event 在root.htaccess中使用此行 RewriteRule ^feondi_event$ /adm/index_pub.php 这不使用.htaccess,但也适用于: <?php if($_GET['ch'] == 'feondi-event') {

我需要一些帮助。这是原始链接

 http://tester.local/adm/index_pub.php?ch=feondi-event
我希望它是这样的

 http://tester.local/feondi_event

在root.htaccess中使用此行

RewriteRule ^feondi_event$ /adm/index_pub.php

这不使用
.htaccess
,但也适用于:

<?php
if($_GET['ch'] == 'feondi-event') {
    header("Location: http://tester.local/feondi_event");
}
?>


重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/adm/index_pub.php?ch=$1[L]

感谢您的回复。但当我测试它不工作。更新它请检查现在可能的副本。无论如何,你不能用mod_rewrite来做这件事。您应该手动处理从重写url中提取的文本。你显然错过了一个机会。
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /adm/index_pub.php?ch=$1 [L]
</IfModule>