繁体   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