htAccess mod_rewrite - 长 URL 的子文件夹类型


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:大写确实很重要,因为谷歌和谷歌将有所不同。

将这段代码放在 .htaccess 中的 DOCUMENT_ROOT:

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]