[英]Creating friendly URLs with mod_rewrite in htaccess?
我已經搜索了這個論壇,並進行了廣泛的Google搜索,但無法弄清楚。 我有很多看起來像的鏈接:
mysite.com/example6.php?id=play-game
mysite.com/example6.php?id=watch-tv
mysite.com/example6.php?id=go-outside
我嘗試了很多不同的代碼,將其放入我的.htaccess文件中:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /example6.php?id=$1 [L]
和
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^id/(.*) example6.php?id=$1
</IfModule>
還有更多嘗試,但沒有任何辦法使我的URL看起來像這樣:
mysite.com/example6/play-game
mysite.com/example6/watch-tv
mysite.com/example6/go-outside
我的服務器上確實啟用了mod_rewrite。 有人有什么想法嗎?
嘗試這個:
RewriteRule ^example6/(.*)$ example6.php?id=$1 [L]
您的第一個示例( RewriteRule ^([^/]*)\\.html$ /example6.php?id=$1 [L]
)可以正確處理“ /play-game.html”之類的網址,而第二個示例( RewriteRule ^id/(.*) example6.php?id=$1
)對於“ / id / play-game”之類的網址將正確工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.