1

我目前使用的是,

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

4

1 回答 1

1

将此代码放在 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]
于 2012-04-16T13:49:05.903 回答