2013-03-21 49 views
1

IAM試圖建立.htaccess文件改寫網址,以便文件擴展名,如.PHP工作和.html被刪除,目前只有404錯誤頁面工程對的.htaccess的.htaccess不通過internetters

網址IAM努力改變中的一個例子是:http://www.thinkbrainstormers.co.uk/clients.php

IAM試圖將其更改爲http://www.thinkbrainstormers.co.uk/clients

<IfModule mod_expires.c> 
ExpiresActive On 
ExpiresByType image/jpg "access plus 1 year" 
ExpiresByType image/jpeg "access plus 1 year" 
ExpiresByType image/gif "access plus 1 year" 
ExpiresByType image/png "access plus 1 year" 
ExpiresByType text/css "access plus 1 month" 
ExpiresByType application/pdf "access plus 1 month" 
ExpiresByType text/x-javascript "access plus 1 month" 
ExpiresByType application/x-shockwave-flash "access plus 1 month" 
ExpiresByType image/x-icon "access plus 1 year" 
ExpiresDefault "access plus 2 days" 
</IfModule> 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html 
ErrorDocument 404 /404.html 

是.htaccess文件

回答

0

您要倒退了:您不會刪除具有重寫條件的擴展名,而是定義將轉至具有擴展名的文件的路徑。這些行:

RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 

......基本上是說「如果文件請求帶有.php擴展名,用.php擴展名調用它」。你需要做的是定義路徑結構,並將這些結構映射到你想要使用的php文件。喜歡的東西:

RewriteRule ^episode/([0-9]+)?$ episode.php?eid=$1 [L] 

...將於url.com/episode/5並將其映射到episode.php?eid=5