Hello Community,
I was wondering if there is a way to make a page look like a subdirectory.
This is what it would look like now http://example.com/page.php this is what i want it to look like http://example.com/sub/page.php

But i don't want to put the page.php in a subdirectory i just want it to look like it is.

Please help...

Recommended Answers

All 9 Replies

add this to .htaccess

RewriteRule ^sub/page.php$ page.php [L]

The styling for the page has gone.

use absolute path for css/js/images..

or try: RewriteRule ^path_to_css_folder$ /path_to_css_folder

Yer i know that would work but then i misewell just put the page in another subfolder.
I just want a way to make it look like the page is in another subfolder not virtually put it in a subfolder.

Well does "making it look like it is in a subfolder" not equal "virtually putting it in a subfolder"? ;) This is the only option I know about that works, but I'm curious as to what others think of this.

Why not just put it in a subfolder? It's not like it'll slow things down or anything.

Member Avatar for diafol

You've been given the correct info. You use an Apache mod_rewrite in your .htaccess file

To ignore your css files, you just add the ^ line.

Here's an example of an old one of mine:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^(js|css)($|/) - [L]
RewriteRule ^([^/]*)/([^/]*)/*$ /index.php?lang=$1&page=$2 [L]
ErrorDocument 404 /404.php

The third line stops rewrite for directories with js or css in them
Ignore the line after that - just my own rewrite

I don't fully understand .htaccess so could you show me how i can use this.
This is what i have so far:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(js|css)($|/projects) - [L]
RewriteRule ^projects/software.php software.php [L]

I'm sure i've done it wrong because there is still no stlying.

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.