سؤال

It's a little difficult for me to ask the question correctly in title, but mainly here's what I'm trying to figure out.

If I use .htaccess on my website and say I'm trying to create a specific path "redirect" so that anything inside that path uses it's non-redirected path for it's relative path. Sorry for the structure of that sentence.

So for example...

I have my website as-

http://www.example.com/

I want to keep things organized so I create a sub-folder/subdirectory to keep all these folders inside of.

http://www.example.com/projects/

So the folder projects will be the place holder for all future projects and I want to create a folder inside projects for each project, so that I can define a URL for each one like such...

http://www.example.com/SuperFish/
http://www.example.com/AquaFear/

Now the folder for SuperFish and AquaFear would be under http://www.example.com/projects/ but also in their own folder say...

http://www.example.com/projects/01/
http://www.example.com/projects/02/

Now it'd be fine and dandy to keep the links like such, but for memory purposes and to share with other people the links to those projects, I'd like to just create a nice simpler URL with a custom "name". like http://www.example.com/SuperFish/ instead of http://www.example.com/projects/01/.

Now I was able to do this partially with my .htaccess file in the root folder with this code...


RewriteEngine On
Options +FollowSymLinks

RewriteRule    ^SuperFish/?$    projects/01/    [NC,L]
RewriteRule    ^AquaFear/?$     projects/02/    [NC,L]

The issue with this though is that now I can't use relative paths with my SuperFish or AquaFear made up URL links. Anything such as .css, .js, .etc... Isn't within scope because it's trying to look for those files through the made up URL rather than the real physical one.

So the question is, how would I make it so that I can use my made up URL and also have the webpage load things to the real physical path or somehow fix the relative paths by doing this within the .htaccess file?

The reason I titled this the way it is, is due to subdomains being able to find their files with relative paths even though they're a subdirectory just the same.

هل كانت مفيدة؟

المحلول

Using final $ blocks files inside this two folders from being redirect correctly. You could tried instead :

RewriteEngine On
Options +FollowSymLinks

RewriteRule    ^SuperFish/?(.*)$    projects/01/$1    [NC,L]
RewriteRule    ^AquaFear/?(.*)$     projects/02/$1    [NC,L]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top