我在网上搜索了一下,试图解决问题,但我不知道怎么解决。
我想将dizisozluk.net/words重定向到dizisozluk.net/ne-demek/anlami/words,并将加号(+)改为破折号(-)。例如
dizisozluk.net/家庭+树
到
dizisozluk.net/ne-demek/anlami/family-tree
我的旧密码在这里
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{THE_REQUEST} /search\.php\?word=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ search.php?word=$1 [QSA,L]
我该怎么改?
提前谢谢。
最佳答案
这样做:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} !\s/+ne-demek/anlami/ [NC]
RewriteRule (.*) https://%{HTTP_HOST}/ne-demek/anlami/$1 [R=301,L,NE]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule .* https://www.%1%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{THE_REQUEST} /search\.php\?word=([^\s&]+) [NC]
RewriteRule ^ /ne-demek/anlami/%1? [R=301,L]
# recursive rule to replace space by - from URI OR query string (anywhere)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?)(?:\+|%20|\s)+(.+?)\sHTTP [NC]
RewriteRule ^ /%1-%2 [L,NE,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ne-demek/anlami/(.+)$ search.php?word=$1 [QSA,L]
关于.htaccess - 创建sef链接和用破折号( - )更改加号(+),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35971406/