Apache htaccess-具有多个变量的漂亮url

Apache htaccess-具有多个变量的漂亮url,apache,.htaccess,mod-rewrite,url-rewriting,friendly-url,Apache,.htaccess,Mod Rewrite,Url Rewriting,Friendly Url,有了您展示的样品,请尝试以下内容。这考虑到您想要点击URL,如:http://localhost:80/sky.php?c=something&id=9&s=anything在浏览器中,应重定向到http://localhost:80/something/9/anything这里 请确保在测试URL之前清除浏览器缓存 RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /sky.php?c=$1&id=$2&s=$3 [L] 欢迎来到SO,感谢您的努力,

有了您展示的样品,请尝试以下内容。这考虑到您想要点击URL,如:
http://localhost:80/sky.php?c=something&id=9&s=anything
在浏览器中,应重定向到
http://localhost:80/something/9/anything
这里

请确保在测试URL之前清除浏览器缓存

RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /sky.php?c=$1&id=$2&s=$3 [L]

欢迎来到SO,感谢您的努力,这意味着您正在点击像
http://localhost:80/sky.php?c=something&id=9&s=anything
在您的浏览器中正确吗?@RavinderSingh13-hmm。。。我在localhost上有这个站点,但是
.htaccess
文件只在远程服务器上,所以所有规则都应该对
example.com/sky.php…
正确,你能确认一下你想点击的网址是:
http://localhost:80/sky.php?c=something&id=9&s=anything
应在浏览器中将其更改为
http://localhost:80/something/9/anything
但仍应由
http://localhost:80/sky.php?c=something&id=9&s=anything
在后端?我就在这里,请确认一下。@RavinderSingh13-如果我不清楚,请原谅。请忘记本地主机
.htaccess
仅在远程服务器上。代码中的所有其他内容都是正确的,只需将
localhost:80
替换为
example.com
Hello vegas,我已经在回答中对此进行了回答,您可以在回答的评论部分进行评论,以讨论更多内容,谢谢。有些地方出了问题。如果您测试了代码,则生成的地址栏是
example.com/sky/something/9
——问题可能是我方面未知的。所以,不管怎样-非常感谢,我会看看原因是什么。一些新的东西-我删除了一个名为
\u htaccess\u old
的旧文件,现在url字符串还可以,但仍然解决了404错误。有一个小的打字错误真的很感谢你的时间和精力你的代码是100%正确,我犯了一个错误重命名文件,对不起
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /sky.php?c=$1&id=$2&s=$3 [L]
RewriteEngine ON
##This rule handles to change from non-friendly URL to friendly URL in browser.
RewriteCond %{THE_REQUEST} \s/(?:[^.]*)\.php\?c=([^&]*)&id=([^&]*)&s=([^\s&]*) [NC]
RewriteRule ^ /%1/%2/%3? [R=301,L]

##This rule internally rewrites friendly url to non-friendly url.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ sky.php?c=$1&id=$2&s=$3  [L]