我正在開發一個PHP應用程序,其中我需要在獲取請求中使用正斜槓代替問號。像:如何使用正斜槓而不是問號發送請求?
www.example.com/article?aid=10 & aname = MY-文章
應改爲
www.example.com/article/10 /我-文章
以下是我的.htaccess:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^articles/(.*)$ articles?q=$1 [L,QSA,B]
我已經嘗試了很多,但無法找到解決方案。這怎麼能做到?
我想轉換/ article?aid = foo&aname = bar到/ article/foo/bar –
@VishalSuri - 你可以用這個做任何事情。你可以有你想要的水平。 Page.php只是您可以獲取信息的着陸頁的一個示例。如果你的文件被稱爲「文章」沒有問題,那麼「levels」的名稱可以按照你的意願調用它們,比如'aid','aname'。我已更新我的帖子 –
Thanx很多。這工作正常。 –