本文介绍了国防部重写初学者的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何改写script.php的?ID = 3295脚本/ 3295 ??

How would I rewrite script.php?id=3295 to script/3295??

和林也想知道,如果有人能解释一下这些3 RewriteConds做:

and Im also wondering if someone could explain what these 3 RewriteConds does:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

非常感谢你。

推荐答案

正如我倒认为要重写 /脚本/ 3295 要求 /script.php?id=3295 ,而不是倒过来,试试这个:

As I rather think that you want to rewrite requests of /script/3295 to /script.php?id=3295 and not the other way round, try this:

RewriteRule ^/script/([0-9]+)$ /script.php?id=$1

但如果你真的想重写 script.php的?ID = 3295 脚本/ 3295 ,试试这个

RewriteCond %{QUERY_STRING} ^(([^&]*&)*)id=([0-9]+)&?([^&].*)?$
RewriteRule ^/script\.php$ /script/%3?%1%4

如果你想使用该规则的.htaccess文件,从模式中删除斜线。

And if you want to use that rule in a .htaccess file, remove the leading slash from the pattern.

要你的第二个问题:测试,如果请求的URI不能被映射到一个现有的常规文件(! - ˚F),而不是现有的目录( - D!),而不是现有的符号链接。(! - →

To your second question: The RewriteCond directives test if the requested URI cannot be mapped to an existing regular file (!-f), not to an existing directory (!-d) and not to an existing symbolic link (!-l).

这篇关于国防部重写初学者的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 09:12