0

I have edited my /etc/hosts file to link domain.com to my localhost. Now when I visited domain.com I want it to get the site contents from domain.com/site/ but only using the URL domain.com thus removing site/ from the URL.

I have done this once before, so I know it's possible, but I lost the code. Can someone please assist me? .htaccess scripting is not my strong. Apologies if this is a duplicate of something else.

2 Answers 2

0

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On RewriteBase / RewriteRule ^((?!site/).*)$ site/$1 [L,NC] 
Sign up to request clarification or add additional context in comments.

5 Comments

Doesn't seem to get contents from site when I go to domain.com
ok comment out both RewriteCond and retry. btw what is location of this .htaccess? Inside ste or a level above?
Hmm that's buggy since that will also block /abcd/site not just /site/, let me provide a more correct version here.
This is only for local development of a Wordpress site using the actual site URL.
Actually if you have WP in site folder then none of the solutions week work.
0

I have managed to get this working with the following code:

Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_URI} !(.*)your_directory RewriteRule ^(.*)$ your_directory/$1 [L] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.