簡體   English   中英

htaccess mod_rewrite-子文件夾類型為長網址

[英]htaccess mod_rewrite - subfolder type to long urls

我目前正在使用的是

RewriteEngine On
RewriteBase /

RewriteRule ^blahblah/([a-z]+)$ abcd.php?word=$1 [L]

因此,當前輸出為site.com/blahblah/word

我想要實現的是site.com/blahblah/the-word-is-word

到處搜索,找不到任何東西:(

范例:

原始網址: site.com/abcd.php?word=Google

當前: site.com/blahblah/Google

我在尋找什么: site.com/blahblah/the-word-is-Google

PS:大寫確實很重要,因為Google和google會有所不同。

將此代碼放在DOCUMENT_ROOT下的.htaccess中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# external redirect to blahblah/the-word-is-google.html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+abcd\.php\?word=([^\s]+) [NC]
RewriteRule ^ blahblah/the-word-is-%1.html? [L,R,NC]

# internal redirect from blahblah/the-word-is-google.html to abcd.php?word=google
RewriteRule ^blahblah/the-word-is-([a-z]+)\.html$ abcd.php?word=$1 [L,NC,QSA]

暫無
暫無

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

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