.htaccess用

编程入门 行业动态 更新时间:2024-10-25 00:23:51
本文介绍了.htaccess用-(“%20"改成“-")重写空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想删除指向-(破折号)的链接的

I want to remove %20 on my link to - (dash),

我的.htaccess现在就是这样,

My .htaccess is like that right now,

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ icerik.php?name=$1 [QSA,L]

例如

site/vision-and-mision, site/do-re-mi-fa-so-la-si.

site/vision-and-mision, site/do-re-mi-fa-so-la-si.

实际上我搜索了一些内容,但信息非常具体,我很困惑

Actually I searched something but the informations were very specific and I'm confused

谢谢.

推荐答案

您可以在/.htaccess文件中使用以下内容:

You can use the following in your /.htaccess file:

RewriteEngine On # Replace whitespace with hyphens, set the environment variable, # and restart the rewriting process. This essentially loops # until all whitespace has been converted. RewriteRule ^([^\s]*)\s(.*)$ $1-$2 [E=whitespace:yes,N] # Then, once that is done, check if the whitespace variable has # been set and, if so, redirect to the new URI. This process ensures # that the URI is rewritten in a loop *internally* so as to avoid # multiple browser redirects. RewriteCond %{ENV:whitespace} yes RewriteRule (.*) /$1 [R=302,L]

然后添加您的规则:

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /icerik.php?name=$1 [QSA,L]

如果这对您有用,并且您想使浏览器和搜索引擎缓存重定向,请将302更改为301.

If this is working for you, and you would like to make the redirects cached by browsers and search engines, change 302 to 301.

更多推荐

.htaccess用

本文发布于:2023-11-01 23:05:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550669.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!