ok i have been working on this for 2 days now here is what im trying to do.

I have urls that look like this www.mysite.com/folder/folder/folder/file.php

What I would like the url to look like the url to look like is www.mysite.com/file.php

I know this can be done with .htacces i just cant figure out how.

If anyone knows how please share, thanks in advance.

Yes I will have more that one subfolder, outside of folder,folder,folder

As I mentioned I have worked on this for days now with no clue anything you can provide is appreciated.

URL rewrites are good for translating set patterns, for example:
www.site.com/products.php?catagory=1&product=32&viewmode=2

to:
www.site.com/products/cat1/item32/2

But if you are using unknown folder structures or varying structures, then it will not be suitable unless you have numerous (and probably complex) rewrite rules.
Also, if you want all files to translate to site.com/file.php then you will need to make sure that every single file has a unique name.

ReWrites are best used for SEO, to the end user they make little difference.

Basically Im just using it to mask or remove the subfolders from the url so maybe it would be easier to just subtract certain folders from urls.

So rather than changing file names can we just subtract folder1,folder2 from all urls on my site? But still display page.

Is this possible if so how?

Could I use something like this for multiple files?

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/free($|/)
RewriteRule ^.*$ /paid/index.html [L]

Or This

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(folder1|folder2|folder3).*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./folder1/folder2/index.php [L]

Ok here is what I figured out, if I use

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/free($|/)
RewriteRule ^.*$ /paid/index.html [L]

and repeat the

RewriteCond %{REQUEST_URI} ^/free($|/)
RewriteRule ^.*$ /paid/index.html [L]

i can mask unlimited folders. If anyone has a better way please let me know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.