0

I've tried some different solutions I've found on the web on my .htaccess file (placed in the root of my website), but I always end up with an "Internal Server Error"...

I need a generic rule to remove a specific folder from the URL and the extension of all the files contained in it (adding a trailing slash at the end), with a redirection to the rewrited url. So, for example:

the folder I want to work on is called "pages", so the rule should not affect any other folder, and I want that the url

http://www.example.com/subfolder/pages/
will be rewrited/redirected to
http://www.example.com/subfolder/

and

http://www.example.com/subfolder/pages/page1.php
will be rewrited/redirected to
http://www.example.com/subfolder/page1/

and

http://www.example.com/subfolder/pages/subpages/page1.php
will be rewrited/redirected to
http://www.example.com/subfolder/subpages/page1/

and so on...

How can I achieve that?

stefano1
  • 203
  • 5
  • 14

1 Answers1

0

This would be more logical in 2 rules:

  1. Remove extension: /subfolder/pages/(.*).[^.]+ -> /subfolder/pages/$1/
  2. Remove pages from URL: /subfolder/pages/(.*) -> /subfolder/$1

Didn't test the rules but this should get you there.

Amblyopius
  • 441
  • 3
  • 2