views:

17

answers:

1

Hello, I have no access to the httpd.conf. How can I redirect the users if the type one folder more like -> http://www.example.com/folder/folder2/ --> redirect 404 to the main page.

The users should only have access to this root http://www.example.com/link+custom1+custom2/

and if they type something like that http://www.example.com/link+custom1+custom2/onemorefolder/orTwo/ --> redirect

how can I do that only with .htaccess and without php?

A: 

Assuming your server has mod_rewrite enabled, you should be able to put this inside a .htaccess file in the root folder of your site, inside a Directory or VirtualHost section:

    RewriteEngine On
    RewriteRule ^(.*)/(.+) / [R=301,L]

That rule will match any URL with a slash and some characters after it, and send a 301 Permanent redirect to the browser (you want a 301 to indicate a redirect, rather than a 404.. search engines will pick this up and adjust their links properly).

zombat