user1680567
user1680567

Reputation: 49

Redirect pages in Sub folder using .htaccess

I have looked all over for the answer but can't seem to get any examples working so I need some help.

I have a website built in PHP (Not using a framework).

I have sub-pages in a folder called /some-work/

So the address to these sub pages is www.domain.co.uk/some-work/page

I want to be able to access this pages by

www.domain.co.uk/page.

Everything I have tried has caused it to change the url in the address but not actually display the page.

Can someone please help?

Upvotes: 1

Views: 50

Answers (2)

anubhava
anubhava

Reputation: 786146

You can use this rule in root .htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^((?!some-work/).*)$ some-work/$1 [L,NC]

Upvotes: 1

Amit Verma
Amit Verma

Reputation: 41249

Try this in your Public_html/.htaccess :

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/?$ /some-work/$1 [L,NC]

Upvotes: 0

Related Questions