Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

.htaccess - Set 410 list of url with space

I have list of url with space on it , And i want to set them as gone (410)

https://www.website.com/Enhanced Category/religions/page/28
https://www.website.com/Enhanced Category/

Im on shared hosting using litespeed server...tried to encode the space on my htaccess

https://www.website.com/Enhanced%20Category/religions/page/28
https://www.website.com/Enhanced%20Category/

but it failed, the url still serve as 404...can anyone help me?

My htaccess

RewriteEngine On
Redirect 410 /Enhanced%20Category
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
RewriteRule ^d{4}/dd/([w-]+.html)$ /$1 [R=301,L]
<Files xmlrpc.php>
Order Allow,Deny
Deny from all
</Files>
Options All -Indexes
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Requested url

   https://www.website.com/Enhanced Category return 404 status
   https://www.website.com/Enhanced%20Category return 410 status
question from:https://stackoverflow.com/questions/65885478/set-410-list-of-url-with-space

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Based on your shown samples, could you please try following. Please make sure you clear your browser cache before testing your URLs, fair warning haven't tested full htaccess file since there are other rules mentioned by OP with my added ones.

<Files xmlrpc.php>
Order Allow,Deny
Deny from all
</Files>

<IfModule mod_rewrite.c>
RewriteEngine ON
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]    
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]

RewriteRule ^d{4}/dd/([w-]+.html)$ /$1 [R=301,NE,L]

RewriteRule ^index.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteRule ^Enhanced%20Category/religions/page/28/?$ - [R=401,L]
RewriteRule ^Enhanced Category/?$ - [R=401,L]
</IfModule>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...