2010-05-25 78 views
4

我是新來的PHP,我試圖學習國防部重寫改寫我的URL我使用godaddy作爲我的託管公司,他們說要添加所需的代碼您的.htaccess文件如何修改我的URL並將其添加到我的.htaccess文件?PHP國防部重寫.htaccess文件godaddy.com問題

有人能給我一個例子,說明如何做到這一點,以及指向我一個很好的教程和或如何mod重寫我的URL的書?

回答

3

http://articles.sitepoint.com/article/guide-url-rewriting

的說明,不過,GoDaddy的通常需要RewriteBase /

快速「N髒

RewriteEngine On 
RewriteBase/
RewriteRule ^/?about/?$ about.php [L,NC,QSA] # domain.com/about is sent to the server as domain.com/about.php 
RewriteRule ^/products/([0-9]+)$ /products.php?id=$1 [L,NC,QSA] # domain.com/products/23 is sent to the server as domain.com/products.php?id=23 
+0

我將不得不爲每個文件夾和子這樣做呢? – max 2010-05-25 04:22:50

+0

僅當您需要特定於他們的規則時。文件夾/ secretArea可能有它自己的htaccess文件,因爲誰知道什麼。通常,您會在網站的根目錄中找到它們。 – 2010-05-25 04:26:10

+0

您對goDaddy需要'RewriteBase /'的評論爲我節省了很多麻煩。 – Manatax 2013-03-04 10:34:55