.htaccessを使用して親しみやすいURLを作成したいと思います。URLから.php拡張子を削除しますが、親しみやすいURLは機能しません。
私はすでにこの
RewriteRule ^pagename/([a-zA-Z0-9]+)/$ projectname/pagename.php?id=$1
のためのソリューションを試してみました。しかし、それはまた、私が持っている
を働いていないのURLの下に
http://localhost/projectname/pagename/1
へ
http://localhost/projectname/pagename.php?id=1
を変換したいです以下に述べるリンクではなく
How to write htaccess rewrite rule for seo friendly url
Creating SEO friendly urls using htaccess
私に.htaccessファイルを右溶液を得
のhtaccessファイルの上に使用してOptions +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase/
RewriteRule ^pagename/([a-zA-Z0-9]+)/$ projectname/pagename.php?id=$1
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule^%1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule^%{REQUEST_URI}.php [L]
私は、URLから.php
拡張子を削除することができますが、SEOフレンドリーなURLを生成しません。
ありがとうございます。
ます(http: //altorouter.com/)を参照してください。 – Abhishek
関数と呼び出し関数を作ってaltorouterを使わずに簡単にURLを変換することができますが、.htacesssを使って実現したいのですが、私は –