Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 .htacsess url重写,参数很少_Php_.htaccess_Url_Url Rewriting - Fatal编程技术网

Php .htacsess url重写,参数很少

Php .htacsess url重写,参数很少,php,.htaccess,url,url-rewriting,Php,.htaccess,Url,Url Rewriting,我有一个网址 https://exmaple.com/param1/param2/param3/so on . 我希望url是 开 这就是我要做的 <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{R

我有一个网址

 https://exmaple.com/param1/param2/param3/so on .
我希望url是

这就是我要做的

    <IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^param1/param2/param3/$ /param1/param3/ [L]
</IfModule>

重新启动发动机
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
重写规则^param1/param2/param3/$/param1/param3/[L]
但上面的url不起作用,无法重定向到404


任何想法

您都可以使用以下规则:

重新编写引擎打开
重写基/
重写规则^-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
#分别匹配参数1、参数2和剩余URI
#捕获组#1中的参数1和组#2中的剩余部分
#我们使用R=301从外部重定向URL
#此规则必须放在最后一个index.php规则之前的顶部
重写规则^([\w-]+)/[\w-]+/([\w-]+/.*)$/$1/$2[L,NE,R=301]
重写规则^index\.php$-[L,NC]
#用于让index.php处理所有非文件/dir URI的前端控制器规则
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。index.php[L]

您可以显示您的完整.htaccess吗?RewriteEngine On RewriteRule ^fussball/land/deutschland/$/fussball/landing/deutschland/[L]这仅在my.htaccessIs
https://exmaple.com/param1/param2/param3/so
在浏览器中加载时工作正常?是的,在RewriteRule上的RewriteEngine工作正常。*-[E=HTTP\U AUTHORIZATION:%{HTTP:AUTHORIZATION}]RewriteBase/RewriteRule^index\.php$-[L]RewriteCond%{REQUEST_FILENAME}-f RewriteCond%{REQUEST_FILENAME}-重写规则/index.php[L]重写规则^param1/param2/param3/$/param1/param3/[L]这不起作用。它重定向到404page@AayushBansal:在本地Apache上设置这些规则后,我将从
/param1/param2/param3/so
重定向到
/param1/param3/so
。您在浏览器中输入了什么URL?@Ayushbansal:有进一步的更新吗?