簡體   English   中英

這些聲明在我的.htaccess文件中意味着什么?

[英]What do these declarations mean in my .htaccess file?

我是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]

如果您是新手,請閱讀http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html ,它的解釋非常好。

ps您的標題“這些聲明在我的PHP .htaccess文件中意味着什么?” 不正確,.htacces不是php文件。

這些說

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

“如果請求與現有文件或目錄不匹配,則僅使用以下規則。”

這些是mod_rewrite配置條目。

它是Apache mod_rewrite規則。 除非您使用某種框架,否則可能不需要它。 有關更多信息,請參見Apache mod_rewrite。

簡單的答案:這些聲明將每個請求重寫為rewrite.php文件。

更全面的答案: RewriteCondRewriteRule指令來自Apache模塊mod_rewrite,並提供基於規則的URL重寫機制。

看來,這些規則是為了重寫每個請求到rewrite.php文件,無論是在一個特定的目錄( /~ foob​​ar的 /rewrite.php )或根( /rewrite.php )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM