我搜索过网络,我试图解决问题,但我无法弄清楚如何。 我想将dizisozluk.net/words重定向到dizisozluk.net/ne-demek/anlami/words并将加号(+)改为破折号( - )。例如
到
我的旧代码在这里
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]
我该怎么改变?
提前致谢。
答案 0 :(得分:2)
这样做:
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]