Forum Moderators: phranque
index.php?a=11&b=$2&c=65&d=3
index.php?a=4
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
RewriteCond %{HTTP_HOST} ^sub.domain.com? [NC]
RewriteCond %{REQUEST_URI} !^/accounts/.* [NC]
RewriteCond %{QUERY_STRING} ^a=4$ [NC]
RewriteRule ^/?index\.php$ http://sub\.domain.com? [L] # Redirect Direct Client Requests For Account Dynamic URL to Static Equivalent Subdomain
RewriteCond %{QUERY_STRING} ^a=4$ [NC]
RewriteRule ^index\.php$ http://sub.domain.com? [R=301,L] # Redirect Direct Client Requests For About Us Dynamic URL to Static Equivalent
RewriteCond %{THE_REQUEST} ^a=28&b=142$
RewriteRule ^index\.php$ http://wantadmag.com/about? [R=301,L]
RewriteRule ^about$ index.php?a=28&b=142 [L] ## About Us URL Now what i am trying to do is take this exact url below
index.php?a=4
and display it as a sub.domain.com
My current dynamic url structure is currently like this
index.php?a=11&b=$2&c=65&d=3
Now what i am trying to do is take this exact url below
index.php?a=4
RewriteCond %{HTTP_HOST} ^sub.domain.com? [NC]
RewriteCond %{REQUEST_URI} !^/accounts/.* [NC]
RewriteCond %{QUERY_STRING} ^a=4$ [NC]
RewriteRule ^/?index\.php$ http://sub\.domain.com? [L] I am aware of the basics and i also am knowledgeable as to the difference between files, folders, rewrites and redirects.
because they are dynamic urls i had to rewrite them first then redirect them
Didn't you just get through saying that your ordinary URL has four parameters? Are they each optional?
index.php?a=4<<<< this displays its own page and whenever any links on that page are clicked the site generates a whole new url query string and or structure
index.php?a=28&b=142<<<<<< this displays its own separate page and the same as the other url if any links on that page are clicked it will do the same and move on to a new page with a completely new query string which could be like the one that gave you the headache lol
index.php?a=11&b=2&c=65&d=3<<<<<<<< Just to clarify the $ was a typo on my part.
I am aware of the basics and i also am knowledgeable as to the difference between files, folders, rewrites and redirects.
Be sure you know the difference between a rewrite and a redirect (both are coded from RewriteRules) and be sure you know when you're dealing with URLs (as used on the web) and files and folders (as used inside the server). They are not at all the same thing; they are merely linked by the server configuration.
because they are dynamic urls i had to rewrite them first then redirect them
This second statement was just to clarify that i am aware that with dynamic query string urls you cannot just 301 redirect them you have to first rewrite them then you can 301 redirect the old url to the new rewritten url.
if you 301 them without first creating the rewrite rule for them they lead to a server error file not found because there is no actual file the links are dynamically created
Are you setting up a pattern where the user's address bar says "subdomain.example.com" while the content really comes from http:example.com (that is, ahem, the physical directory that resolves to http://example.com) /index.php?a=4Yes this is correct.
Do your URLs --the ones seen and used by humans-- currently contain query strings?yes this is also correct i will try to explain it better.
http://example.com/index.php?a=10This link dynamically creates the page by making the call to index.php and the following query string. Now once the user logs in they are then redirected to the url and page in question
http://example.com/index.php?a=4. Every url produces and displays its own page and content by making the call to index.php and then the correct content is displayed based on the query string following index.php so in other words here are a few example links
Home URL >>> index.php
Pricing URL >>> index.php?a=28&b=143
About Us URL >>> index.php?a=28&b=142
Contact Us URL >>> index.php?a=28&b=136
Sell URL >>> index.php?a=1
Accounts URL >>> index.php?a=4
Signin URL >>> index.php?a=10
Do your URLs --the ones seen and used by humans-- currently contain query strings?The urls i have posted above are exactly the way the user's see them in their browser and they are also used by the users.
Do requests for this particular subdomain get sent straight through to some directory that already existsNo there is no directory as each page is dynamically created by making the call to index.php then the query string after index.php determines what content should display on that page. So for example a=4 is the query that pulls up the accounts page and content. Wildcard subdomains are already being used for US regions on my site so what i wanted to do is create a subdomain in cPanel called "accounts" and have "accounts" point to the root domain (same server) at "http://example.com" which is where the index.php file is located and accounts.example.com must get its content from. Unless the rule for index.php?a=4 can be used and rewritten as a wildcard [accounts.domain.com...] without causing any conflict.
RewriteCond %{THE_REQUEST} [A-Z]{3,9}\ /index\.php\?a=4\ HTTPThis rule isn't working. If a click the old "index.php?a=4" link it just takes me to the page displaying this original link. Also if i type accounts.example.com directly in my browser it just loads to the home page at example.com I also tried adding the [QSA] flag but that still didn't make a difference.
RewriteRule ^index\.php [accounts.example.com...] [R=301,L]
RewriteCond %{HTTP_HOST} ^(accounts)\.example.com? [NC]
RewriteRule ^$ http://example.com/index.php\?a=4? [R=301,P,QSA,L]
http://example.com/index.php?a=4%3f
[edited by: ItsDavid at 1:20 pm (utc) on Feb 27, 2013]
http://example.com/index.php?a=4
RewriteCond %{HTTP_HOST} ^accounts\.example.com [NC]
RewriteRule ^$ http\://example\.com/index.php\?a=4 [R=301,QSA,L]
http://example.com/index.php?a=4
[edited by: g1smd at 3:04 pm (utc) on Feb 27, 2013]
# Redirect Direct Client Requests For About Us Dynamic URL to Static Equivalent
RewriteCond %{THE_REQUEST} ^a=28&b=142$
RewriteRule ^index\.php$ http://example.com/about? [R=301,L]
RewriteRule ^about$ index.php?a=28&b=142 [L] ## About Us URL
Define in terms of requested URLs (things with http at the beginning) that the user requests,
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?a=4\ HTTP/
RewriteRule ^(index\.php)?$ http://accounts.example.com/? [R=301,L] RewriteCond %{HTTP_HOST} ^accounts\.example\.com$
RewriteRule ^$ /index.php?a=4 [L]