Chris
Chris

Reputation: 58182

htaccess root/subfolder and root/subfolder/ into root/subfolder2/subfolder/

I want to be able to enter the following into the URL:

https://mydomain.com/fork or https://mydomain.com/fork/

And for both to goto a subfolder called

https://mydomain.com/prod/fork_contents/index.html

But still only display https://mydomain.com/fork (or https://mydomain.com/fork/, either way)

I would like index.html to act as the root so all the image urls, etc still work (they are relative to '/prod/fork_contents/')

Currently the .htaccess in the root is:

ErrorDocument 404 /live/site_documents/document404.html
ErrorDocument 403 /live/site_documents/accessDenied.html


Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/$

RewriteRule ^fork$ /fork/index.html [L,QSA]
RewriteRule ^fork/$ /fork/index.html [L,QSA]

RewriteRule ^fork/(.*)$ /prod/forklift_contents/$1 [L,QSA]

Thoughts?

Upvotes: 0

Views: 390

Answers (1)

Ibu
Ibu

Reputation: 43810

You can use the question mark for optional charters

RewriteRule ^fork\/? /prod/fork/$1 [L]

For a very good tutorial on rewriting check this website .htaccess tips and tricks..

Upvotes: 2

Related Questions