Forum Moderators: phranque

Message Too Old, No Replies

I need some smart help for URL Rewriting rules

         

cipherion

7:12 pm on Oct 27, 2012 (gmt 0)

10+ Year Member



I'm kinda new to apache and I have the following situation, which I need help with :) .

I have a vps, on which I have set the following:
WordPress Site A, has it's own VirtualHost and domain
WordPress Site B, has it's own VirtualHost and domain
Canvas LMS (not connected to a domain).
Canvas LMS can add multiple accounts, which may (or may not) be accessed individually using a URL that looks as follows:
{canvas_root}/accounts/{account_id}/

For example:
[.........]

I need to add a link to each of WP sites, which points to each site's account on Canvas, such that it appears as .../learning/ folder

For example:

http://WPSiteA/learning/
http://WPSiteB/learning/

which actually represents

http://WPSiteA/accounts/4/
http://WPSiteB/accounts/5/

which in turn represents

http://{my_vps_ip}/accounts/4/
http://{my_vps_ip}/accounts/5/

respectively

Noticing the following:
I do not want the users to see the /account/4/ , just /learning/
I also want to prevent accessing
Canvas LMS is located beyond the website's DocumentRoot
I want this to work with both HTTP and HTTPS
That's a lot I know , but I really appreciate your help :)

Thanks guys!

cipherion

7:14 pm on Oct 27, 2012 (gmt 0)

10+ Year Member



I'm sorry, there's something misformatted here. In the third paragraph there should have been a url like:
http:// whateverdomainname / accounts/4/

g1smd

8:06 pm on Oct 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



See [webmasterworld.com...]

The post edit button is below your user name.

lucy24

10:07 pm on Oct 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not any more it isn't. You only get about an hour :)

cipherion

4:46 am on Oct 28, 2012 (gmt 0)

10+ Year Member



Thanks guys, that was quick :)

@g1smd, thanks for your help. I went to the link mentioned, but it only contains the "standard" redirect rule, which doesn't really satisfy what I'm looking for. Can you provide more detailed help?

wilderness

5:08 am on Oct 28, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you provide more detailed help?


The link that g1smd provided is the second thread on the top of the forum page and was placed there to provide insight to newcomers to use example.com when expressing domain names, so that the forum software does not provide a link to functioning HTTP links. (i. e., your For example: )

Should you wish one of the forum participants to assist you?
It's a good idea to read the forum charter and forum library to make the task of assisting you as easy as possible.

By NOT using example.com you've merely provided that you failed to read the forum charter and/or library.

lucy24

5:45 am on Oct 28, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's not totally clear from your first post what the recurring pattern is. There has to be some way for mod_rewrite to know how to get from Point A to Point B.

You imply that there are more redirects involved than just the two you give as examples. Are you talking about some finite number, or something that can expand dynamically? If there's no built-in limit, you're going to need to rewrite to a php script (or equivalent in language of your choice) that translates from Original Request to New Request and winds up by issuing the Redirect.

The link was not, ahem, intended to help with your Rewrite-to-Redirect two-step, just to draw your attention to "example.com". But you can do a Forums search for "rewrite + redirect + boilerplate"; that's your starting point. I re-post it every month or so.

Make sure you're rock solid on the difference between Rewrite and Redirect, because you will be using both.

cipherion

9:01 pm on Oct 28, 2012 (gmt 0)

10+ Year Member



Ah, ok, I'm sorry for that mistake. Please notice that I'm not a native English speaker, so I can easily misunderstand :D

I like this forum, people are really helpful and friendly. Thanks to all of you :)

@lucy24 , let explain. I have a server with several domains pointing to, each with a VirtualHost. What I want is to have the following link:
http://www.example.com/elearning (or: [edu.example.com...] seamlessly access the service that is normally accessed through [{ip_address}...] noticing that this service resides outside the DocumentRoot, and that it's a pramater/value pair. So, it does not have an actual mapping on the disk.

Thanks in advance :)

lucy24

9:42 pm on Oct 28, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are we talking about subdomains?* If so, each RewriteRule will need a preceding Condition looking at the {HTTP_HOST}. Even if they all end up in different places, all requests will have to pass through your config file first.

How many subdomains will there be? Are they dynamic (that is, you might make a new one at any time) or is there a fixed number?

So, it does not have an actual mapping on the disk.

But your final destination has a real, physical location. I assume things are set up with the DNS so all subdomains point to your server.

Will there be much overlap in filenames? That is, complete paths like
directory/otherdirectory/filename.html
It is definitely easier if no two subdomains have the same exact filenames.

Even if there is no other overlap, you will have to deal with requests for
subdomain.example.com/ = subdomain.example.com/index.html
othersubdomain.example.com/index.html

et cetera. Whether these pages exist or not, users will ask for them, so you have to include a rule.

:: still trying to figure out what key it is that makes my entire post-- not just the text but the Compose box itself-- disappear** so I have to revert to an earlier version and try to remember what I added since then ::


* This is where "example.com" falls apart. You can say

http://www.example.com
or
http://www.example.pt
or
http://www.example.xyz (really)

but you can't say
http:/ /subdomain.example.com

without extra spaces or other trickery. Darn it all.

** Whatever it is, I've hit it by accident several times. The cat alas cannot be blamed. Don't know what would happen if I hit Submit.