문제

I have used the following rule for my URL rewriting. It works fine up to the second parameter. But when I use with the third parameter, it is not working. For example, I use http://example.com/1/2/3 and it is not working, but with http://example.com/1/2 it is working.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(\w+)$ ./index.php?api=$1
RewriteRule ^([^.]+)/([0-9]+)$ index.php?api=$1&id=$2
RewriteRule ^([^.]+)/([0-9]+)/([a-zA-Z0-9]+)$ index.php?api=$1&id=$2&action=$3 
도움이 되었습니까?

해결책 2

Try this, It worked for me.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(\w+)$ ./index.php?api=$1
RewriteRule ^(\w+)/([0-9]+)$ index.php?api=$1&id=$2
RewriteRule ^(\w+)/([0-9]+)/([a-zA-Z0-9]+)$ index.php?api=$1&id=$2&action=$3 

다른 팁

This solved my problem.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(\w+)$ ./index.php?api=$1
RewriteRule ^(\w+)/(\w+)$ index.php?api=$1&id=$2
RewriteRule ^(\w+)/(\w+)/(\w+)$ index.php?api=$1&id=$2&action=$3 
RewriteRule ^(\w+)/(\w+)/(\w+)/(\w+)$ index.php?api=$1&id=$2&action=$3&k=$4 
RewriteRule ^(\w+)/(\w+)/(\w+)/(\w+)/(.*)$ index.php?api=$1&id=$2&action=$3&k=$4&v=$5 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top