大家好我正在使用这个,我知道htaccess正在工作,因为它重定向到notfound.php但是由于某种原因我不能让它工作以不显示扩展名(php / html)这里有任何帮助?
<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
答案 0 :(得分:1)
您需要的不仅仅是支持隐藏.php
和.html
扩展程序所需的内容。请考虑以下代码:
通过httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放在.htaccess
目录下的DOCUMENT_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]