user3312792 user3312792 - 2 months ago 14
Apache Configuration Question

prepend directory to all urls mod rewrite

I am using htaccess on localhost, my htaccess is:

RewriteEngine On
RewriteBase /website/files/

RewriteRule ^home/?$ home.php [NC]
RewriteRule ^page/?$ page.php [NC]

This url works:


But when hovering over links on the page they are displayed as:


Instead of:


All links in the page are set as:

<a href="/page">page</a>

How can I prepend the directory to all urls in htaccess?


Create this .htaccess in the site root .htaccess:

RewriteEngine On

RewriteRule .* website/files/$0 [L]

Keep your website/files/.htaccess as you've shown in question.