2

Suppose the user request for the content such as image in www.example.com/content/img/one.jpg.

If the one.jpg is in the directory img then the image is served. But if the one.jpg is not present then user is redirected one directory up to www.example.com/content/one.jpg.

Whether it has the requested file or not.

It must be valid for all content such as images or documents or videos etc.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ______________________

Thanks

4

1 回答 1

1

您可以在DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?/)?[^/]+/(.+)$ $1$2 [L]
于 2015-04-05T06:07:56.790 回答