2017-04-04 2 views
0

.htaccess 파일과 URL 재 작성에 약간의 도움이 필요합니다. 나는 여기서 모든 질문과 답변을 찾았고 나는 그것에 매달렸다..htaccess를 사용하여 URL에서 공백과 html 특수 문자를 제거하십시오.

그래서 공백 % 20을 -으로 대체하는 데 도움이 필요합니다.

현재 URL http://localhost/blog/Blog%20of%20the%20day

여기 내 htaccess로 파일

RewriteEngine On 
# Removes .php extension from inner_blog.php 
RewriteRule ^blog/?$ blog.php [NC] 
# Remove inner_blog.php and changing it to blog/articlename 
RewriteRule ^blog/([^/]*)$ /inner_blog.php?title=$1 [L] 
# Need to replace %20 with - from URL 
# Current URL http://localhost/blog/Blog%20of%20the%20day 
# Need to be http://localhost/blog/Blog-of-the-day 
# Was like http://localhost/inner_blog.php?title=Blog%20of%20the%20day 

답변

0
// Start or After "/" 
RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L] 

// End or Before "/" 
RewriteRule ^(.+?)[\s%20]+(/.*|)$ $1$2 [L] 

내가 이전 프로젝트에서이 문제가 발생하여이 스레드에서 대답을 얻었다입니다. 참조를 들어

: htaccess clean urls & replacing whitespaces and %20 with -

+0

난에 공백을 대체해야 확인 -하지만 여전히 난 깨끗한 URL –

+0

anybosy을 geeting하고 있지 않다하여이 문제를 해결할 수 –

관련 문제