user3312792
user3312792

Reputation: 1111

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:

http://localhost/website/files/home

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

http://localhost/page

Instead of:

http://localhost/website/files/page

All links in the page are set as:

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

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

Upvotes: 1

Views: 400

Answers (1)

anubhava
anubhava

Reputation: 785128

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.

Upvotes: 0

Related Questions