是否需要使用mod_rewrite – 馬永占 譯

來源:互聯網
上載者:User

著作權聲明:原創作品,允許轉載,轉載時請務必以超連結形式標明文章原始出版、作者資訊和本聲明。否則將追究法律責任。http://blog.csdn.net/mayongzhan - 馬永占,myz,mayongzhan

原文地址:http://www.phpguru.org/#212

最近php-general mailinglist 正在討論關於mod_rewrite。我的觀點很簡單,不需要,請看下文:
/rental/property/23425
你可能認為上面的那個地址是rewrite的結果。你錯了。是在.htaccess中使用了如下內容:
<Files rental>
    ForceType application/x-httpd-php
</Files>
檔案被apache當作PHP指令碼來執行。意思是你可以使用REQUEST_URI這個伺服器變數來得到提交的URL,然後顯示內容。
 
 
 
 
Recent discussion on the php-general mailing list regarding mod_rewrite. My opinion is that if your needs are simple - it's not necessary. Consider:
/rental/property/23425
You may think that mod_rewrite is necessary here. It's not. Simply place this in a .htaccess file:

<Files rental>
    ForceType application/x-httpd-php
</Files>
Now the file "rental" will be parsed by Apache as a PHP script. This means you can use the REQUEST_URI server variable to get the requested URI and show the appropriate content.
This is exactly how the "static" directory is done on this site. It's actually not a directory at all, but a PHP file that looks at the URL and determines the correct content to show.
 
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.