segon
segon

Reputation: 273

Mamp and RewriteBase

I use Mamp free version. I want to work local. For instance, make links work inside htdocs/site1 as they were in the root. To test I tried this:

Inside htdocs I have 2 folders: site1 and site2
Inside site1 I have 2 files: file1.php and file2.php
Inside site1 I have .htaccess with this:

RewriteBase /site1/

Inside file 1 I have a link to check if I can use absolute link. It does not work:

<a href="/file2.php" >go to file 2</a>

Is RewriteBase a good way to make links work in local?. How to do that?

Upvotes: 0

Views: 453

Answers (1)

anubhava
anubhava

Reputation: 785038

make links work inside htdocs/site1 as they were in the root

You will just need this single rule in htdocs/.htaccess (a level above site1)

RewriteEngine On

RewriteRule ^((?!site1/).*)$ site1/$1 [NC,L]

You don't need .htaccess insidesite1for this, you can remove thatRewriteBase` line.

Upvotes: 1

Related Questions