반응형
.htaccess rewrite url에 변수 2개 포함
제 것에 문제가 있습니다..htaccessrewrite rule (저는 처음이라 아마 쉬운 일일 것입니다.)
다음 URL을 가지고 있습니다.
http://www.example.com/film-al-cinema/?titolo=Ghost+in+the+Shell&id=315837
그래서 첫 번째 변수 안에 영화 제목이 들어있습니다.titolo=""그리고 두번째 변수에 있는 영화의 ID.id="".
나는 URL이 다음과 같길 원합니다.
http://www.example.com/film-al-cinema/Ghost+in+the+Shell/315837
htaccess 파일을 다음과 같이 변경하려고 했습니다.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^film-al-cinema/(.*)/([0-9]+)$ film-al-cinema/?titolo=$1&id=$2 [R]
</IfModule>
404쪽으로 방향이 바뀌었습니다
편집
제가 워드프레스 작업을 하고 있기 때문에./film-al-cinema/워드프레스 페이지입니다.
EDIT 2
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^film-al-cinema/([^/]+)/(\d+)/?$ /index.php?page_id=21016&titolo=$1&id=$2 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
이 방법을 사용해 보시고 효과가 있는지 알려주십시오(업데이트).
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /film-al-cinema\/\?titolo=([^\s&]+)&id=([^\s&]+) [NC]
RewriteRule ^film-al-cinema\/$ /film-al-cinema/%1/%2? [R,L]
RewriteRule ^film-al-cinema/([^/]+)/([^/]+)/?$ /film-al-cinema/?titolo=$1&id=$2 [NC,L]
현재 .htaccess 파일의 백업을 만든 다음 이 코드를 사용해야 합니다.모든 것이 잘 작동한다면 추가합니다.R=301대신에R맨 끝줄에
언급URL : https://stackoverflow.com/questions/43756116/htaccess-rewrite-url-with-two-variables
반응형
'programing' 카테고리의 다른 글
| 모든 열에 대한 Oracle 열 너비 (0) | 2023.10.29 |
|---|---|
| 두 개의 열이 포함된 각 그룹에서 마지막 레코드를 가져오는 MySQL 쿼리 (0) | 2023.10.29 |
| New-Object : "PSCredential" 및 인수 개수 "2"에 대한 오버로드를 찾을 수 없습니다. (0) | 2023.10.29 |
| 아바다 테마에 jQuery 코드를 삽입하는 방법은? (0) | 2023.10.29 |
| detach(), hide() 및 remove()의 차이점 - jQuery (0) | 2023.10.29 |