开发者

How do i do a 301 redirect to a specific location

开发者 https://www.devze.com 2023-03-28 10:57 出处:网络
I want to remove the slash of 1 and only 1 url this snippet will remove them all # Remove the trailing slash

I want to remove the slash of 1 and only 1 url

this snippet will remove them all

# Remove the trailing slash
Rewrit开发者_开发问答eCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]

but i just want to change

example.com/changeme/ 

to

example.com/changeme

any ideas how to change this htaccess i have to only do it on one


You could replace (.+) with (changeme) in RewriteRule:

RewriteRule ^(changeme)/$ http://www.example.com/$1 [R=301,L]

This will only match 'changeme' and not everything.

In this way you can also match multiple URLs, including e.g. 'changeother' and 'foobar':

RewriteRule ^(changeme|changeother|foobar)/$ http://www.example.com/$1 [R=301,L]


How about this?

RewriteRule ^changeme/$ http://www.example.com/changeme [R=301,L]


All you need is (as long as this rewrite is only applied to example.com):

RewriteRule ^changeme/$ changeme [R=301,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消