我需要这样的网址:
http://domain.com/subfolder/file.php?src=quick-brown-fox&m=1&size=320x480
..改为:
http://domain.com/subfolder/file/quick-brown-fox/320x480
我用以下内容更新了htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/subfolder/([^\.]+)$ $1.php [NC,L]
但是我得到了404.我做错了什么?
答案 0 :(得分:1)
您可以在子文件夹/ .htaccess
中执行此操作Options -MultiViews
RewriteEngine On
RewriteBase /subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?(.*)$ $1.php [NC,L]
然后在php中捕获URI。
答案 1 :(得分:0)
您可以在/subfolder/.htaccess
中使用此规则:
Options -MultiViews
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^(file)/([^/]+)/([^/]+)/?$ $1.php?src=$2&m=1&size=$3 [QSA,NC,L]