eozzy
eozzy

Reputation: 68650

URL Rewriting for sub-folder

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?

Upvotes: 0

Views: 56

Answers (2)

Panama Jack
Panama Jack

Reputation: 24448

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.

Upvotes: 1

anubhava
anubhava

Reputation: 784898

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]

Upvotes: 0

Related Questions