Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.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 301将动态url重定向到重写的url_Php_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php 301将动态url重定向到重写的url

Php 301将动态url重定向到重写的url,php,.htaccess,mod-rewrite,url-rewriting,Php,.htaccess,Mod Rewrite,Url Rewriting,我想重定向所有动态链接以重定向到其重写的url,例如: 到 我的访问权限: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /ads-detail.php?location=$1&id=$2&name=$3 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f Rew

我想重定向所有动态链接以重定向到其重写的url,例如:

我的访问权限:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /ads-detail.php?location=$1&id=$2&name=$3 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]*)/([^/]*)$ /ads-detail.php?id=$1&name=$2 [QSA,L] –

尝试了很多我没有任何解决方案请帮助,提前感谢

在您的htaccess中尝试以下内容:

 RewriteEngine on
#1) redirect "/ads-detail.php?location=foo&id=123&name=bar" to "/foo/123/bar"
RewriteCond %{THE_REQUEST} /ads-detail.php\?location=([^&]+)&id=([^&]+)&name=([^\s]+) [NC]
RewriteRule ^ /%1/%2/%3? [NC,L,R]

#2) if the requested  is not for an existing directory
RewriteCond %{REQUEST_FILENAME} !-d

 #3) then rewrite "/foo/123/bar" to "ads-details.php"
 RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /ads-detail.php?location=$1&id=$2&name=$3 [NC,L]

请共享您的解决方案和当前的htaccess这是我的.htaccess代码重写cond%{REQUEST_FILENAME}-f RewriteCond%{REQUEST_FILENAME}-重写规则^([^/]*)/([^/]*)/([^/]*)$/ads detail.php?位置=$1&id=$2&name=$3[QSA,L]重写条件%{请求文件名}-f RewriteCond%{REQUEST_FILENAME}-重写规则^([^/]*)/([^/]*)$/ads detail.php?id=$1&name=$2[QSA,L],实时url为:我想重定向到: