0

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 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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] 

5 Comments

I'm already doing $request = $_SERVER['REQUEST_URI']; $params = explode("/", $request); in the file.php just need to redirect to that file
You can avoid explode and directly get it using $_GET array and yes $_SERVER['REQUEST_URI'] is still available.
Unfortunately it didn't. The problem with using query string is that it keeps on changing, so its better if I handle it inside PHP
Unless you write what doesn't work I can't help you. Start with simple answer to this? What happens when you enter http://domain.com/subfolder/file/quick-brown-fox/320x480 in browser? Do you get any error or what?
Nevermind about the query string, I just need to know how all requests to file.php no matter if they're http://domain.com/subfolder/file/quick-brown-fox/320x480 or just http://domain.com/subfolder/file

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.