子文件夹的URL重写
问题描述:
我需要这样的网址:
http://domain.com/subfolder/file.php?src=quick-brown-fox&m=1&size=320x480
..更改为:
http://domain.com/subfolder/file/quick-brown-fox/320x480
我用以下方式更新了htaccess:
I updated the htaccess with:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/subfolder/([^\.]+)$ $1.php [NC,L]
但是我得到了404.我在做什么错了?
but I'm getting a 404. What am I doing wrong?
答
您可以在subfolder/.htaccess中这样做
You could do this in subfolder/.htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?(.*)$ $1.php [NC,L]
然后在php中捕获URI.
Then capture the URI in php.