2017-12-22 14 views
0

.htaccess 다시 쓰기 규칙을 사용하고 있습니다. 내 규칙을 모두 완벽하게 작동하는.htaccess mod 다시 쓰기 규칙을 사용하는 경우 PHP 쿠키를 사용할 수 없습니다.

Options -MultiViews 

RewriteEngine on 
RewriteRule ^Login login.php [NC,L] 
RewriteRule ^Register register.php [NC,L] 
RewriteRule ^Posts/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+) posts.php?category=$1&subcategory=$2 [NC,L] 

하지만 문제는 여기에 있습니다 : 내가 액세스하는 경우

<a href='Login'>Login</a> from website home page it is redirecting to login.php that is perfectly working 

하지만 난

<a href='Login'>Login</a> from website posts page it is redirecting to Posts/login.php which is incorrect. It should redirect to login.php only. 

이 난을 해결하기 위해 액세스하는 경우 로그인 버튼에 직접 페이지를

으로 사용함3210
<a href='http://www.mywebsite.com/Login'>Login</a> 

완벽하게 작동하지만 문제는 모든 페이지의 쿠키에 도시 이름을 유지해야하므로 사용할 수없는 쿠키입니다.

내 웹 사이트의 링크를 확인 : 내가 홈 페이지에있어 같은 http://fidfeet.com/Login, http://fidfeet.com/Categories/Login

먼저 하나가 작동,하지만 난이 카테고리 페이지에있어 둘째가 작동하지 않습니다.

+0

쿠키를 사용하지 않더라도 세션에 도시 이름을 등록 할 수 있습니다. https://www.w3schools.com/php/php_sessions.asp – danielarend

답변

0

링크가 상대 경로를 가리키고있어 하위 사이트에서 동일한 위치로 확인되지 않습니다. root에서 Login을 참조하려면/Login을 가리켜 야합니다.

쿠키는 첫 번째 쿠키부터 정의한 후 두 번째 경로에서 사용할 수 있습니다. 오른쪽 상단에 선택한 도시가 나열된 상자가 있습니다.