Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Aug 15, 2010 10:19 pm 
Offline
Senior Newbie

Joined: Sat Mar 27, 2010 12:32 am
Posts: 6
Hi,

I am using NGINX as my webserver and i have a question which i really dont know if it is technically doable. So i start to explain.

1.) I have categorized my web pages under my root so i have lets say 20 different folders and each folder has its .html pages in it. I have to mention that this is a STATIC website. So for example we will have pages like:

Code:
www.mydomain.com/folder-A/bla-bla-bla-bla.html
www.mydomain.com/folder-B/talk-talk-talk.html
www.mydomain.com/folder-C/bip-bip-bip.html


2.) Ok... so now comes the part that i am interested in. Can i give some rewrite rule to NGINX so that NGINX removes the folder part from each url? Like a 301 redirect so the urls look like:

Code:
www.mydomain.com/bla-bla-bla-bla.html
www.mydomain.com/talk-talk-talk.html
www.mydomain.com/bip-bip-bip.html


I know i can do this by simply throwing ALL .html files into the ROOT directory but the website is very large and has about 3000 .html web documents. So it would be better if i can categorize these 3000 .html files into folders BUT it would be nice that the actual URL shows up different without the folder part.

Is this doable? Without havening duplicate content and being penalized from Google. If this is doable... can someone guide me, give me an eample or help me out somehow to do it right? With a correct 301 permanent redirect etc?

Thanks in advance

George


Top
   
 Post subject: Nginx rewrite's
PostPosted: Mon Aug 16, 2010 6:04 am 
Offline
Senior Newbie

Joined: Thu Mar 11, 2010 10:42 am
Posts: 15
ICQ: 33922655
Location: Ireland
The only way I can think of is to incorporate the folder name into the URL using a delimiter. This wont shorten your URL at all, but there must be some piece of information in the ultimate URL to let NGinx now where the file is. You can remove the folder slashes and replace with a delimiter, for example "--"... This example is for a simple one folder deep layout as you specified.

Code:
rewrite ^/(.+)--(.+)$ /$1/$2 permanent;


Ultimately I don't think you can gain much in terms of shortening, but if you just really want to ditch the folder slashes that can be done easy enough (as above)

_________________
Linode 512 @ cbr250.com


Top
   
 Post subject:
PostPosted: Mon Aug 16, 2010 10:30 am 
Offline
Senior Member

Joined: Sat Feb 14, 2009 1:32 am
Posts: 123
Do you not want to move the files simple because of the time it would take to move each file from the subdirectory to the parent? If so, a simple Bash script would do it for you.


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2010 1:20 am 
Offline
Senior Newbie

Joined: Sat Mar 27, 2010 12:32 am
Posts: 6
carmp3fan wrote:
Do you not want to move the files simple because of the time it would take to move each file from the subdirectory to the parent? If so, a simple Bash script would do it for you.


I dont want to move the files because i would end up having in the root directory 3000 different .html files... I want to have them organized in directories but i want a different url for the files.

Thanks

George


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2010 4:46 pm 
Offline
Senior Member

Joined: Sun Feb 21, 2010 5:12 pm
Posts: 64
I can't think of a GOOD solution.

1. Could do 3000 symlinks from root to subdirectories. Script to keep them up to date.

2. Could have nginx scan all 20 directories. Then enable caching with a long expire if your content doesn't change often.

3. Could list all 3000 addresses in a file and use nginx map module to hash em and use them in a single redirect.

Without referring to some list or actually testing the locations, how else can nginx know where to find the file?


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2010 8:47 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
I don't know about nginx, but in lighttpd, I'd probably reach for a lua script. See this blarg post for a tangentially-related thing.

... but, if there's a way to "embed" the directory name in the URL somehow, I like the regex idea mentioned previously. Simple and good.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group