问题
I want it so that if the user types webaddress.com/artist/P1/P2/ it will make it use /artist/index.php?artist=P1&am=P2
P1 would be an artist name, so it could contain both letters and numbers. P2 would be a number, so just numbers.
I want it so that P1 would be esssential, whereas P2 isn't because right now it just returns 404 not found on that address. Current code:
RewriteEngine on
RewriteRule ^artist/([^/]+)/(\d+)/$ /artist/index.php?artist=$1&am=$2 [L]
回答1:
/artist/index.php implies there is a root directory on the server call /artist/. I somehow doubt this (and it it does exist, it shouldnt).
Remove the leading / before artist, and see if that works.
RewriteEngine on
RewriteRule ^artist/([^/]+)/(\d+)/$ artist/index.php?artist=$1&am=$2 [L]
来源:https://stackoverflow.com/questions/21223329/htaccess-rewrite-returns-404-not-found