URL Rewriting for sub-folder

2019-09-11 08:03发布

I need a URL like this:

http://domain.com/subfolder/file.php?src=quick-brown-fox&m=1&size=320x480

.. changed to:

http://domain.com/subfolder/file/quick-brown-fox/320x480

I updated the htaccess with:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/subfolder/([^\.]+)$ $1.php [NC,L]

but I'm getting a 404. What am I doing wrong?

2条回答
地球回转人心会变
2楼-- · 2019-09-11 08:34

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]

Then capture the URI in php.

查看更多
再贱就再见
3楼-- · 2019-09-11 08:40

You can have this rule in /subfolder/.htaccess:

Options -MultiViews
RewriteEngine On
RewriteBase /subfolder/

RewriteRule ^(file)/([^/]+)/([^/]+)/?$ $1.php?src=$2&m=1&size=$3 [QSA,NC,L]
查看更多
登录 后发表回答