2016-08-30 8 views
0

この一般的な問題を処理するために、私は多くのソリューションをStackOverflowで見つけましたが、セットアップにはうまくいかないものがあります。私はPHPのページにリンクしたとき、私はまだ拡張子.phpを見て、私は、フォルダのウェブサイト "内WAMP/localhostのを使用してサイトに取り組んでいます.htaccessを使用して.pht拡張子を削除するための書き換えルール

index.php updated to 'website' 

about-us.php to be website/about 

持っていると思います。私は自分の.htaccesファイルを 'website'フォルダのルートの中に置いています。

index.phpと他のPHPページから.php拡張子を削除するために使用しようとしている書き換え条件/ルールはこれです。

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

私のリンクはURLのこの

<a href="index.php"> 
<a href="about-us.php"> 

等を有していて、ここではそれがリダイレクトとして動作し、URLから.phpを "削除" は、実際にはありませんフルの.htaccessファイル

RewriteEngine On 
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

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

## EXPIRES CACHING ## 
<IfModule mod_expires.c> 
ExpiresActive On 
ExpiresByType image/jpg "access 1 year" 
ExpiresByType image/jpeg "access 1 year" 
ExpiresByType image/gif "access 1 year" 
ExpiresByType image/png "access 1 year" 
ExpiresByType text/css "access 1 month" 
ExpiresByType application/pdf "access 1 month" 
ExpiresByType application/x-javascript "access 1 month" 
ExpiresByType application/x-shockwave-flash "access 1 month" 
ExpiresByType image/x-icon "access 1 year" 
ExpiresDefault "access 2 days" 
</IfModule> 
## EXPIRES CACHING ## 

<IfModule mod_deflate.c> 
# compress text, html, javascript, css, xml: 
AddOutputFilterByType DEFLATE text/plain 
AddOutputFilterByType DEFLATE text/html 
AddOutputFilterByType DEFLATE text/xml 
AddOutputFilterByType DEFLATE text/css 
AddOutputFilterByType DEFLATE application/xml 
AddOutputFilterByType DEFLATE application/xhtml+xml 
AddOutputFilterByType DEFLATE application/rss+xml 
AddOutputFilterByType DEFLATE application/javascript 
AddOutputFilterByType DEFLATE application/x-javascript 
</IfModule> 

# Or, compress certain file types by extension: 
<files *.html> 
SetOutputFilter DEFLATE 
</files> 

答えて

1

です。 つまり、他のユーザーにあなたのURLに.phpが表示されないようにするには、すべてのリンクを修正する必要があります。

すなわち<a href='www.example.com'>

<a href='www.example.com/about-us'>

<a href='www.example.com/blog'>

あなたは、スクリプト内のすべてのリンクを修正する必要があります。

関連する問題