2
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d # not an existing dir
RewriteCond %{REQUEST_FILENAME} !-f # not an existing file
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}\.php -f # and page.php exists
# redirect to the physical page
RewriteRule ^(.*)$ $1.php [L]
# otherwise, redirect to serve.php
RewriteRule^/serve.php [L]
RewriteRule ^(\w+)$ ./serve.php?id=$1
コードの最初の部分では、httpをhttpsに変換するだけです。私の目的は、.php
なしでURLを使うことができるということですが、私の古いコードでは、私がそうした場合、私のserve.phpページのidとして使用されてしまうという問題がありました。だからhttps://example.com/contact
を使用する場合はhttps://example.com/serve.php?id=contact
のようになりましたが、それはhttps://example.com/contact.php
として動作しますが、反対側では、その方向またはファイルがIDとして動作する必要があります。私の古いコードは...htacessにファイルとIDを区別させる方法
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(\w+)$ ./serve.php?id=$1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
神はあなたを祝福、最終的にはいけない誰かが重複のために私をレポートしますが、実際のために役立ちます。そのように行こう! –
私はあなたに7分でバッジを与えます.. –