0

大家好,我正在使用它,我知道 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
4

1 回答 1

1

好吧,您需要的不仅仅是支持隐藏.php.html扩展。考虑这段代码:

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.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]
于 2012-04-25T16:33:41.123 回答