Forum Moderators: phranque
RewriteRule ^self-service/$/index.php?systemtemplate=ss-site
does [domain.com...] and [domain.com...]
count as two different addresses point to the same content aka duplicate content?
The answer may seem obvious to some, but I have to confirm.
Question #2
More of a "how to" request, than a question. How would you go about redirecting...
/client-login/ to a secure (port:443) /ccc-login.php?systemtemplate=one-offs
(i.e. [domain.com...] to [domain.com...] (where the latter is pointing to [domain.com...] behind the scenes)?
# ----------------INTIALIZE------------------ #
AddDefaultCharset utf-8
RewriteEngine on
Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.php
# Redirect of domain.com/whmcs/ to /today/ ###
RewriteRule ^$ http://beta.domain.com/today/ [R=301,L]
RewriteRule ^client-login/$/ccc-login.php?systemtemplate=one-offs
RewriteCond %{SERVER_PORT} !=80
RewriteRule ^client-login/$ https://beta.domain.com/$1 [R=301,L]
# Primary Links
RewriteRule ^self-service/$/index.php?systemtemplate=ss-site
Thx in advance
Taine
One of the toughest things to understand is that mod_rewrite makes clear the distinction between a URL and a filename. Before you added your rewrite, the URL was http://example.com/index.php?systemtemplate=ss-site and the filename was probably similar to /username/www/index.php?systemtemplate=ss-site. In order to derive the filepath from the URL, the server only had to strip the domain name from the request, and add the path defined as DocumentRoot. In simple terms, the URL-path was equal to the server-relative filepath, and one might say "they were the same." This is the usual case (most webmasters don't rewrite URLs).
But now that you've added your rewrite and changed the links that appear on your Web pages, the URL has changed to http://example.com/self-service. while the filename has stayed as it was before. The URL and the filepath are now quite obviously "not the same."
However, since you have not added any code to prevent it, the old URL will still work. So, you *may* need to add a redirect from the old URL to the new one, in order to speed up the change-out of the old URL in search engine listings, and to prevent 'accidental' linking to the old URL.
This is a bit tricky, because the code has to look at the client request to be sure that the old URL is being directly requested by the client, and not as a result of your new rewriterule, before a redirect is invoked. If you don't make this distinction, then this new redirect and your internal rewriterule will countermand each other, and the results will be an 'infinite' loop.
In this case, the redirect would look something like this:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?systemtemplate=ss-site\ HTTP/
RewriteRule ^index\.php$ http://example.com/self-service/? [R=301,L]
And now this brings in question number two... In order to prevent exposure of your internally-rewritten filepaths due to the action of external redirects, it is important to order your rules so that external redirects ([R=30x]) go first, in order from most-specific to least-specific, and are then followed by your internal rewrites, again in order from most- to least-specific.
Jim