Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Advanced URL rewriting
PostPosted: Sun Feb 28, 2010 6:27 pm 
Offline
Newbie

Joined: Sun Feb 28, 2010 6:20 pm
Posts: 2
Website: http://www.weareworkingonit.com
Location: Netherlands
Hi guys! and girls. :)

First post here, ive been googling like mad and decided to go out and ask for help. I've hit a wall up here and whas hoping people here could help and point me in the right direction.

I've got a website wich needs some advanced url rewriting. Perhaps the thing i want to archieve isn't possible, but i doubt that.

I have a site wich is powered by wordpress with prety url rewrites. What i want to archieve is to look at the url and see if it has mydomain.com/products/productname" and then rewrite those pages to "productname.mydomain.com"

Is this possible with mod rewrite? Note that the url's are already being rewritten using:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,L]

# BEGIN WordPress
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


Top
   
 Post subject:
PostPosted: Sun Feb 28, 2010 6:57 pm 
Offline
Senior Newbie

Joined: Tue May 20, 2008 8:39 pm
Posts: 10
Something like:

Code:

RewriteMap upper2lower int:tolower

Rewriterule ^/products/(.*) http://${upper2lower:$1}.domain.com [R=301,L]


?

Checked on my server and works ... the upper2lower just keeps things tidy lowercase.

Check here

http://tools.web-max.ca/requestinfo.php

with

stayau.com/product/yerrrrrrrr
stayau.com/product/BLING

However, if u have PHP access, I'd tend to rewrite to a PHP file which can then check if the product exists, and do the 302 from there via a header() command.


Top
   
 Post subject:
PostPosted: Sun Feb 28, 2010 7:32 pm 
Offline
Newbie

Joined: Sun Feb 28, 2010 6:20 pm
Posts: 2
Website: http://www.weareworkingonit.com
Location: Netherlands
Mmm doesnt seem to have any affect when i add the line into my htacces.

I'm not to good with rewrites and editing htacces. might just be doing something wrong. Could it be because of the default wordpress rules?


Top
   
 Post subject:
PostPosted: Mon Mar 01, 2010 9:12 am 
Offline
Senior Newbie

Joined: Tue May 20, 2008 8:39 pm
Posts: 10
Hmmm, sucky answer - "but works for me"

Should be at the start ( after "RewriteEngine On" )

Also, if I get this right from ur htaccess you check to see if the domain doesn't start with domain.com and then [301] to http://www.domain.com

So if the line isn't at the start, it will probably work, then come back in, see that it doesn't being with domain.com and redirect it back.

Which means you also need to remove

Code:
RewriteCond %{HTTP_HOST} ^domain.com 
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,L]


( Unless you are going to a seperate virtual host )


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


Who is online

Users browsing this forum: No registered users and 3 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