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?

4

1 回答 1

0

这在两条规则中会更合乎逻辑:

  1. 删除扩展名:/subfolder/pages/(.*).[^.]+ -> /subfolder/pages/$1/
  2. 从 URL 中删除页面:/subfolder/pages/(.*) -> /subfolder/$1

没有测试规则,但这应该能让你到达那里。

于 2013-02-18T15:38:21.910 回答