views:

66

answers:

2

I'm trying to convert all requests in the format:

/portfolio/picturename.htm

('portfolio' is constant)

to this:

/?picturename

So (thanks to users here) I have this solution which works for files that don't exist:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^portfolio/(.+)\.htm$ /?$1 [R,NC,L]

But: How do I also have this apply to files that exist? I'd like the redirect to happen under all circumstances.

+2  A: 

This should work for all files, whether they exist or not. RewriteRule doesn't check for file existence, RewriteCond does. Are you posting the full content of your .htaccess file, or only the part you think is important?

Roel
Roel. Thanks for that, it made me go back and check my htaccess...and comment out a part that was mucking things up when implementing suggestions previously.
+2  A: 

There's nothing about that RewriteRule that would make it only apply to files that don't exist. It would need this before it for that condition:

RewriteCond %{REQUEST_FILENAME} !-f
chaos