I know it seems duplicated question: I searched a lot, I applied tens of rewrite rules but they don't work.
I need to redirect from
www.domain.com/folder1
to
www.domain.com/folder1/subfolderA
Note: folder1 is emtpy. in subfolderA I have index.html, index.php, css file, js files. If I go to "www.doman.com/folder1/subfolderA/" I see a simple web page with correct css and js provided by index.php file.
My .htaccess file is in www.domain.com/ (I've tried to put it in folder1 but it doesn't work, even removing "RewriteBase /" line). File permssions: 0755.
"Option -Indexes","Option +Indexes" generate error "Option indexes not allowed here", so I deleted them.
"Options +FollowSymLinks" generates error "Option FollowSymLinks not allowed here" and I deleted it.
RewriteBase /
RewriteRule ^/folder1(/.*)?$ /folder1/subfolderA$1 [L,R]
(rif: https://stackoverflow.com/a/32525136/1315873) ('R' is just for debug)
Results:
www.domain.com/folder1/subfolderA/subfolderA/subfolderA/subfolderA/subfolderA/
RewriteBase /
RewriteCond %{HTTP_HOST} !subfolderA [NC]
RewriteRule ^/folder1(/.*)?$ /folder1/subfolderA$1 [L,R]
Perfect for http://htaccess.madewithlove.be/ but not for my server.
Results:
www.domain.com/folder1/subfolderA/subfolderA/subfolderA/subfolderA/subfolderA (unchanged)
RewriteBase /
RewriteCond %{HTTP_HOST} !subfolderA [NC]
RewriteRule ^/folder1/$ /folder1/subfolderA/ [L,R]
Results:
Forbidden
Log says: "No matching DirectoryIndex (index.html,index.htm,index.php,index.php3,index.phtml,index.shtml,index.wml) found, and server-generated directory index forbidden by Options directive"
If I add to the url "index.php" or "index.html" the result is "404 Not found" (that's true actually).
I don't know what else to do. I hope in your help.
It's an impossibile redirect to do?
Thank you.
I find the right way to do :P The .htaccess file look like this:
RewriteBase /
RewriteCond %{REQUEST_URI} !subfolderA [NC]
RewriteRule ^/?folder1(/.*)?$ /folder1/subfolderA$1 [L,R]
As I don't wont to change url in browser (one must see "www.domain.com/folder1/"), I remove ",R" from last line.
I hope it can be of help to someone else.
You can create an index.php or index.html page in folder1 that will redirect users to subfolderA
e.g index.php can contain the following code
<?php
header("location: subfolderA");
? >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With