[英]Remove .php and add trailing slash in url using htaccess not loading css
[英].Htaccess remove all .php, paramater and add slash in url
我有以下 .htaccess 文件,它幫助我將http://domain/profile.php?uid=1重寫為http://domain/1
RewriteEngine on
#this removes .php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteRule ^(.+)$ /profile?uid=$1 [QSA,NC,L]
但是當我在 url 上添加斜杠時,它也會給我錯誤,我如何添加另一個參數,例如:
http://domain/profile.php?uid=1§ion=about
到
你可以用這個
RewriteEngine on
#remove .php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)/?$ /$1.php [NC,L]
#rewrite /1/about
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/(.+)/?$ /profile?uid=$1§ion=$2 [QSA,NC,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.