我是PHP的新手。任何人都可以告诉我每条线在这里做什么。我需要这个吗?它给了我错误

RewriteCond %{REQUEST_URI} /~([^/]+)/?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /~%1/rewrite.php?p=$1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} /~([^/]+)/?
RewriteRule ^index\.php?(.*)$ /~%1/rewrite.php?p=%1&%{QUERY_STRING} [L]
#there is no ~ character in the URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) ./rewrite.php?p=$1&%{QUERY_STRING} [L]
RewriteRule ^index\.php?(.*)$ ./rewrite.php?p=$1&%{QUERY_STRING} [L]
#WJ-180 fix
RewriteRule ^resume\.php?(.*)$ ./rewrite.php?p=resume\.php$1&%{QUERY_STRING} [L]
有帮助吗?

解决方案

简单的答案:这些声明会将每个请求重写为 rewrite.php 文件。

更全面的答案: RewriteCond RewriteRule 指令来自 Apache模块mod_rewrite 并提供基于规则的URL重写机制。

似乎这些规则旨在将每个请求重写到 rewrite.php 文件中,或者在特定目录中重写( /〜 foobar /rewrite.php )或在根目录中( /rewrite.php )。

其他提示

如果您是新手,请阅读 http://httpd.apache。 org / docs / 1.3 / mod / mod_rewrite.html ,它解释得非常好。

p.s。您的标题“这些声明在我的PHP .htaccess文件中意味着什么?”是不正确的.htacces不是php文件。

这些说

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

"如果请求与现有文件或目录不匹配,则仅使用以下规则。“

这些是 mod_rewrite 配置条目。

它是一个Apache mod_rewrite规则。除非你使用某种框架,否则你可能不需要它。有关详细信息,请参阅Apache mod_rewrite。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top