Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.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
Apache 使用htaccess的URL友好_Apache_.htaccess_Url_Mod Rewrite - Fatal编程技术网

Apache 使用htaccess的URL友好

Apache 使用htaccess的URL友好,apache,.htaccess,url,mod-rewrite,Apache,.htaccess,Url,Mod Rewrite,有下面的URL,但只有第一个与我的htaccess代码一起工作。请帮助修复这两个url的时间。多谢各位 URL 1: 输出:(这没问题) 网址2: 输出:(这不正常) 预期产出: 您可以使用: Options -Multiviews RewriteEngine on RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+)&jid=([^\s&]+) [NC] RewriteRule ^ /%1/%2? [R=302

有下面的URL,但只有第一个与我的htaccess代码一起工作。请帮助修复这两个url的时间。多谢各位

URL 1:

输出:(这没问题)

网址2:

输出:(这不正常)

预期产出:

您可以使用:

Options -Multiviews
RewriteEngine on

RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+)&jid=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=302,L]

RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA,L]

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?id=$1&jid=$2 [L,QSA]

你好,阿努巴瓦,谢谢你的快速回复。但它仍然不起作用。(URL 2:Output:(这不好)预期输出:)非常讨厌anubhava。我接近输出,需要对php代码进行一些修复。再次感谢。
Options -Multiviews
RewriteEngine on

RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+)&jid=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=302,L]

RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA,L]

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?id=$1&jid=$2 [L,QSA]