簡體   English   中英

Htaccess 重寫漂亮的 URL

[英]Htaccess Rewrite Pretty URL

我的問題可能有一個非常簡單的答案,但經過數小時的瀏覽,我仍然沒有找到解決方案,因此非常感謝您的幫助。 也許我應該提到我正在使用 Bluehost 的子域(同一帳戶上的多個域)。

我想重寫: www.example.com/myfolderwww.example.com/index.php?s=myfolder

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /index.php?s=$1 [L]
  • example.com/abcd -> 作品
  • example.com/abcd/ -> 有效但破壞了我的圖片 URL
  • example.com/abcd/index.php -> 不起作用(將我重定向到主頁)

非常感謝您的幫助。 羅蘭

你檢查過這個: https : //aloneonahill.com/blog/url-rewriting-for-beginners

和: 用 PHP 重寫 URL

RewriteRule 上的 RewriteEngine ^/?Some-text-goes-here/([0-9]+)$ /picture.php?id=$1

要重寫為索引,請使用:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/?$ /index.php?s=$1 [L]

對於 css、腳本或圖片,請使用絕對鏈接(以/http://...開頭)或在 html 頭中添加<base href="/">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM