다음 htaccess 코드를 사용하여 URL을 깨끗한 URL로 리디렉션하지만, 이제는 원래 URL을 새 정리 URL로 리디렉션해야합니다.stackoverflow.com URL과 같은 데이터베이스 값을 쿼리하여 리디렉션
예
원본 URL :
example.com/search/store_info.php?store=113&dentist=Dr.%20John%20Doe
청소 URL : 나는 "CLEAN URL로 리디렉션 할 수있는"ORIGINAL URL "입니다 무엇이 필요
example.com/search/113/dr-john-doe
". 이유가 필요한 이유는 두 URL이 모두 Google 검색에 나타나기 때문입니다.
원래 URL 만 사용하면 클린 URL로 자동 리다이렉트해야합니다. 그것은 현재 그렇게하지 않습니다.
여기 내 htaccess 파일입니다. 나는 RedirectMatch에 대해 읽은
ErrorDocument 404 default
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /search/
RewriteCond %{QUERY_STRING} .
RewriteCond %{THE_REQUEST} /store_info\.php\?store=([a-z0-9]+)&dentist=([^\s&]+) [NC]
RewriteRule^%1/%2/? [L,NE,R=301]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_URI} \.(?:jpe?g|gif|bmp|png|ico|tiff|css|js)$ [NC]
RewriteRule^- [L]
RewriteRule ^([a-z0-9]+)/([^\s.]*)[.\s]+(.*)$ $1/$2-$3 [NC,DPI,E=DONE:1]
RewriteCond %{ENV:DONE} =1
RewriteRule ^([0-9a-z]+)/([^\s.]+)$ $1/$2 [R=301,NE,L]
RewriteRule ^([a-z0-9]+)/([a-z0-9-]+)/?$ store_info.php?store=$1&dentist=$2 [QSA,L,NC]
</IfModule>
그러나 나는 여기서 내 htaccess로 파일로 구현하는 방법을 모른다.
가 리디렉션되지 않습니다 @anubhava .. 내가 example.com/search/store_info.php'로 이동, 그래서 만약 가게를 = 113'를 빼고 " & dentist = Dr. % 20John % 20Doe "URL에서 원래 URL로 이동하고 클린 URL 버전으로 변환하지 않습니다. 'example.com/search/store_info.php? store = 113'도 깨끗한 URL로 이동하는 곳으로 변경하려고합니다. 'Redirect 301 /search/store_info.php?store=118 http : // www.example.com/search/118/John-Doe-Dental-Group/' – antivinegar
나는' & dentist = Dr. % 20John % 20Doe'는 이전 페이지의 버튼으로 URL 문자열에 추가됩니다. 그래서'example.com/search/ store_info.php? store = 113'은 URL로부터 치과의 사 이름을 붙잡고 htaccess 파일을 사용하여 깨끗한 URL을 만드는 원래의 URL입니다. – antivinegar
@anubhava 그래서 [this]와 같이 할 방법이 없습니다. (http://stackoverflow.com/questions/38453161/rewriting-old-urls-to-pretty-urls-and-redirect-old-urls- to-new-with-htaccess)? web.config 파일에 방법이 있다는 것을 알고 있습니다. 하지만 htaccess에서 알아낼 수는 없습니다. – antivinegar