Forum Moderators: open
I want my link that was:
domain.com/page.asp?aid=123
to be something like:
domain.com/page-aid-123.htm
The problem is that I can't use the hyphen. The programmers use the hypen sometimes in the value of a string (-1 = null) and it would mess up the rewriting. Also, if I want to dump the title of the page into the URL the best way to do that Google-wise as far as keywords in a URL are concerned is to separate them with hyphens. The underscore is also used to separate values (q=12_5_6). We also can't use slashes before the filename (domain.com/indentifier/page/aid/123.htm)because then we would not be able to use relative paths and would have to recode alot of our site. A comma also won't work since we use that to separate multiple values (&q=12,456,768)
We never use the tilde (~) in a variable so we don't have to worry about messing up values, but it looks strange having a tilde in a URL.
Any ideas? What have others done?
My pages which are rewritten for instance all take the (rather ugly) form /.*\.php\var1/val1/.../varN\/valN so I set up a rewritecond which only handles urls of this form and loop through the rule N times (very early in my rules) to extract each variable as &&varN=valN. As long as I dont name a directory "something.php" and give it two (or more) subdirectories then my rule will handle only the pages which I intend it to and will ignore all else - but this is only because I am able to rather narrowly define my rule and that which it should and should not act upon.
'~' is rather ugly, first and foremost it is used by apache to signify user homedirs via one of the modules, and second it is ugly. Provided you have a function which outputs your hyperlinks '_' or '-' could be made safe via a function call to encode url parameters (which is advisable whether or not you make use of these symbols) and similar decoding on a global include. I find for my sites I like / best because it makes extra parameters look like a deeper version of a page - which in many ways they are.
domain.com/whatever-you-want.htm -> domain.com/index.php?page=whatever-you-want&#rest-of-query#
It wouldn't be entirely much more difficult to make it do something like:
domain.com/whatever-keywords-page-aid-543.htm ->
domain.com/index.asp?aid=543&#rest-of-query#
It'd simply be something like this in the apache conf or htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/
RewriteRule ^/(.*?)-aid-(.*?).html /index.asp?aid=$2&%{QUERY_STRING}
The problem is that I can't use the hyphen. The programmers use the hyphen sometimes in the value of a string (-1 = null) and it would mess up the rewriting.
This should not present a problem in itself. I do believe there are ways to easily work around this.
Also, if I want to dump the title of the page into the URL the best way to do that Google-wise as far as keywords in a URL are concerned is to separate them with hyphens.
Eek! I wouldn't recommend dumping any title elements into file names. That would make for a very unsightly URI and also present some usability and maintenance issues. One, two, three word file names maximum (two hyphens, no more than that if possible).
The underscore is also used to separate values (q=12_5_6).
I personally don't recommend the use of underscores in any file naming structure if it can be avoided.
We also can't use slashes before the filename (domain.com/indentifier/page/aid/123.htm)because then we would not be able to use relative paths and would have to recode alot of our site.
You may have to bite the bullet and change your coding strategies. The relative paths may possibly cause issues with your rewrite to begin with. I strongly recommend that you move to absolute URIs with all ISAPI rewrites.
I don't like the LinkFreeze product. Why? Probably because we are a ISAPI_Rewrite user for the past couple of years. Yes, they are from the same company. The LinkFreeze product is for the DIY (Do-It-Yourself) no server access user. The ISAPI_Rewrite product is much more robust and does require a global .ini file at the root of the server. Once that is done by the host, you can then drop unlimited .ini files in each root and/or virtual root of websites hosted on that server.
Best delimiter using ISAPI
Slashes and Dashes
So if I don't want to recode my easiest option is LinkFreeze with tildes.
But is there any other solution out there that any one is aware of that work for me?
So if I don't want to recode my easiest option is LinkFreeze with tildes.
I think easiest option in this case is a bandaid fix and the long term implications are far more severe.
But is there any other solution out there that any one is aware of that work for me?
Yes. Restructure the site to be more search engine and URI rewrite friendly. The easy way out in this scenario may cause you long term grief. There are others here who will attest to that.
We need the functionality of LinkFreeze so we don't have to recode all link refrences in the html to the new schema (linkfeeze not only interprets a schema but also sends the new schema back to the client).
Using Tilde in URI [google.com]
I'll reiterate Slashes and Dashes.
Working with relative URIs in an ISAPI Rewrite environment is not suggested.
I have not yet heard a clear reason why not to use tildes. The site quoted by pageoneresults "Why tilde (~) should not be used in Web addresses (URLs)" itself uses a tilde! (/~jkorpela/tilde.html)
Can someone please be more specific as to why the tilde solution is NOT good? That it will adversely affect something? I believe that it WILL help in ranking and take away the "dynamic" perception of our site (?'s) thereby increasing deep indexing which is our problem.
Let's face it - dynamic URLs are huge anyway and the purpose we are talking about here is not for marketing the url, but so the search engine sees something other than name-value pairs! If you are going to market a URL you would certainly a) buy a whole new url or b) create a sub-domain (something.yoursite.com) or c) create a sub-directory (yoursite.com/something) and then track for marketing purposes.
According to the W3.org site, a '~' is one of the 'unreserved' characters just like most of the characters you would use in a URL, including '-' and '_'. Here is a snippet from their site: (if you notice, they classify a '~' right alongside '-' and '_'.)
-Frank
<BEGIN>
2.3. Unreserved Characters
Data characters that are allowed in a URI but do not have a reserved
purpose are called unreserved. These include upper and lower case
letters, decimal digits, and a limited set of punctuation marks and
symbols.
unreserved = alphanum ¦ mark
mark = "-" ¦ "_" ¦ "." ¦ "!" ¦ "~" ¦ "*" ¦ "'" ¦ "(" ¦ ")"
Unreserved characters can be escaped without changing the semantics
of the URI, but this should not be done unless the URI is being used
in a context that does not allow the unescaped character to appear.
<END>