user3312792 user3312792 - 1 year ago 79
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download