2012-04-25 116 views
0

嗨,大家好,我正在使用这个,我知道htaccess正在工作,因为它重定向到notfound.php但由于某种原因,我无法让它工作不显示扩展名(PHP/HTML)的任何帮助这里?htaccess删除扩展

<Files ~ "^\.(htaccess|htpasswd)$"> 
deny from all 
</Files> 
Options Indexes 
ErrorDocument 404 notfound.php 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www\.socialscenes\.co\.uk)(:80)? [NC] 
RewriteRule ^(.*) http://socialscenes.co.uk/$1 [R=301,L] 
DirectoryIndex index.php  
order deny,allow 

回答

1

那么你将需要比你要支持隐藏.php.html扩展什么等等。考虑以下代码:

启用mod_rewrite的,并通过httpd.conf的.htaccess,然后把这个代码在你.htaccessDOCUMENT_ROOT目录:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

## hide .php or .html extension 
# To externally redirect foo.php ot foo.html to foo 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.(php|html) [NC] 
RewriteRule^%1 [R,L,NC] 

## To internally redirect /dir/foo to /dir/foo.html 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule^%{REQUEST_URI}.html [L] 

## To internally redirect /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule^%{REQUEST_URI}.php [L]