开发者

.htaccess rewriterule redirect to a page in a subfolder as long as the real page nonexistant

开发者 https://www.devze.com 2022-12-17 09:33 出处:网络
FTR, this is most definitely a programmer shortcoming. The problem is that I\'ve got a short url rewriterule on that works fine. I can do www.mysite.com/matt and it\'ll hit my php page that queries fo

FTR, this is most definitely a programmer shortcoming. The problem is that I've got a short url rewriterule on that works fine. I can do www.mysite.com/matt and it'll hit my php page that queries for a result. But what I NEED is to do mysite.com/music/matt

When I use the same rule for a subfolder as I did on the root dir, it throws a 500 error, AND tries to redirect my mysite.com/music/index.php both of which are a big problem.

Here's what I have that works fine on root (i.e. mysite.com/matt redirects as expected):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}开发者_开发百科 !-d
RewriteRule ^(.*)$ /music/artist_page.php?n=$1 [L,QSA]

If I try the following, I get an internal 500 error and it appears to eat any existing files.

RewriteRule ^music/(.*)$ /music/artist_page.php?n=$1 [L,QSA]


Your substitution destination music/artist_page.php is also matched by ^music/(.*)$ and thus you’re getting a recursion. The first condition in your first rule avoids that for that rule as it excludes any request that can be mapped to an existing file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号