I have a website that is rewritten so URLs are .html
eg: mysite.com/about-us.html
I'm going to add a search feature in which could have a number of different criteria. So my question.... I know the following would work ok as I tried it:
mysite.com/search.html?var1=xxx&var3=xxx
Is there any reason why I should do this as html pages generally wouldn't have variables? I will test, but would there be any browser issues (old browser perhaps)? Any SEO disadvantages?
Thanks :)
Of course ".html"-files can contain variables.
It is not dependent of the Browser but the Server Configuration.
The Server respectively the php-parser must adjusted to parse .html files.
But I don't think that ".html" ending are relevant for google see:
https://webmasters.stackexchange.com/questions/5333/url-rewrite-should-i-write-a-fake-file-suffix-html-or-something-more-realis)
I have a site on a subdomain (www.website.com/foobar) which pulls the default page view. Due to the nature of MVC apps, this default page view can also be reached through the "controller/action" URL of the default content (www.website.com/foobar/{controller}) and (www.website.com/foobar/{controller}/{action}).
For the sake of analytics and tracking, I would like any of these other URLs, besides the original short (www.website.com/foobar), to redirect back to this shorter URL.
So...
www.website.com/foobar/{controller}, when typed in, or clicked on in a bookmarked link, should redirect to www.website.com/foobar
I've tried playing around with the routing, but couldn't get anything to actually change the URL itself. I'm not sure if it's possible to change through mapping.
Edit: Has anyone used the HTTP Redirect within IIS7? I can redirect from the top tier, but cannot seem to get the redirect to work on any of the Views.
I don't think you can use routing alone to redirect up a domain. I had a similar issue and after a few days of searching and asking around, I ended up using Redirect itself to get over the issue. Hope this helps.
I was able to solve the problem in IIS 7 by using the HTTP Redirect module. Because it's an MVC application it was a little trickier to setup a redirect on a view, but it's possible. I used this tutorial: Creating a redirect in IIS7
Edit: While the above solution works, it tended to be unpredictable. I ended up solving it by reading the URL the user was inputting in the Index action of the Quote controller, and then redirecting if keywords I was looking for were in the URL. Just a simple if statement at the beginning of the Index action.
I'm trying to create a small system where people can fill in info, including their web site address. Only, some people will enter "www.example.com", some will enter "http://www.example.com", and some will enter "example.com".
What is the most clean way to:
Validate al URLs, in the sense that they all are including http:// so when I click on it I get redirected correctly, and also
For the visible text on the link, what's the easiest way to get the version without http://?
I could of course go crazy with some conditional text replacements, but there has to be a nicer way to do this.
I will to this way that I check that address begins with http(s):// if not then add it. Don't do anything with example.com and www.example.com because it can destroy whole address.
So you can write:
url = 'http://' + url unless url =~ /\Ahttps?:\/\//
I'd recommend using a gem for this -- there's no reason to try to write all this yourself.
Here's one that may fit your needs. There may be others, but this one seems useful and has a decent following:
https://github.com/conickal/validates_url_format_of
I have a Facebook Connect application (IFrame, external website).
When i post to the user's wall using the Old JavaScript API (FB.Connect.streamPublish), im specifying action links, as many people do.
Here's the JSON for my action link:
[{ 'text':'Do something on my site', 'href':'http://www.mysite.com/somerestfulpath' }]
Now, we use URL Rewriting on my website, so the URL's are all nice and RESTful (i.e. no .ASPX).
Now, for some reason, the link that gets rendered out on the user's wall is:
http://www.mysite.com/somerestfulpath?ref=nf
Of course this is 404'ing.
It seems to be this way for all Facebook apps (not just mine), that for any custom action link, Facebook will automatically append ref=nf to the URL.
For other parts of the post (links, images, etc), they don't do this.
So the only think i can do is change the link to the un-RESTful URL:
http://www.mysite.com/pages/actualpagewhichidontwantuserstosee.aspx
Then it will render:
http://www.mysite.com/pages/actualpagewhichidontwantuserstosee.aspx?ref=nr
Which works.
But WTF, why are they doing this? And can they not give those applications with URL rewriting an option for them not to supply this?
I was hoping to keep the URL's all clean and rewritten.
EDIT:
My bad, the regex rules on the URL rewriter wasnt correct. Burn.
PEBKAC (Problem Exists Between Keyboard And Chair).
My regex rules for this particular page was not foolproof enough.
For anyone that cares, this is what i had:
<rewrite url="^~/somepage$" to="~/Pages/SomePage.aspx" processing="stop" />
This is what i changed it to:
<rewrite url="^~/somepage(.*)" to="~/Pages/SomePage.aspx" processing="stop" />
Also, i was wondering why in Fiddler i was getting all these 404 errors coming from Facebook.
Turns out i was registering the 'xd_receiver.htm' wrong:
FB.Init('myapikey', 'xd_receiver.htm')
So on ALL pages, Facebook was looking for the file relative to the path.
It needed to be:
FB.Init('myapikey', '/xd_receiver.htm')
Never forget the '/'. =)
When I look at Amazon.com and I see their URL for pages, it does not have .htm, .html or .php at the end of the URL.
It is like:
http://www.amazon.com/books-used-books-textbooks/b/ref=topnav_storetab_b?ie=UTF8&node=283155
Why and how? What kind of extension is that?
Your browser doesn't care about the extension of the file, only the content type that the server reports. (Well, unless you use IE because at Microsoft they think they know more about what you're serving up than you do). If your server reports that the content being served up is Content-Type: text/html, then your browser is supposed to treat it like it's HTML no matter what the file name is.
Typically, it's implemented using a URL rewriting scheme of some description. The basic notion is that the web should be moving to addressing resources with proper URIs, not classic old URLs which leak implementation detail, and which are vulnerable to future changes as a result.
A thorough discussion of the topic can be found in Tim Berners-Lee's article Cool URIs Don't Change, which argues in favour of reducing the irrelevant cruft in URIs as a means of helping to avoid the problems that occur when implementations do change, and when resources do move to a different URL. The article itself contains good general advice on planning out a URI scheme, and is well worth a read.
More specifically than most of these answers:
Web content doesn't use the file extension to determine what kind of file is being served (unless you're Internet Explorer). Instead, they use the Content-type HTTP header, which is sent down the wire before the content of the image, HTML page, download, or whatever. For example:
Content-type: text/html
denotes that the page you are viewing should be interpreted as HTML, and
Content-type: image/png
denotes that the page is a PNG image.
Web servers often use the file extension if the file is served directly from disk to determine what Content-type to assign, but web applications can also generate pages with any Content-type they like in response to a request. No matter the filename's structure or extension, so long as the actual content of the page matches with the declared Content-type, the data renders as intended.
For websites that use Apache, they are probably using mod_rewrite that enables them to rewrite URLS (and make them more user and SEO friendly)
You can read more here http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
and here http://www.sitepoint.com/article/apache-mod_rewrite-examples/
EDIT: There are rewriting modules for IIS as well.
Traditionally the file extension represents the file that is being served.
For example
http://someserver/somepath/image.jpg
Later that same approach was used to allow a script process the parameter
http://somerverser/somepath/script.php?param=1234&other=7890
In this case the file was a php script that process the "request" and presented a dinamically created file.
Nowadays, the applications are much more complex than that ( namely amazon that you metioned )
Then there is no a single script that handles the request ( but a much more complex app wit several files/methods/functions/object etc ) , and the url is more like the entry point for a web application ( it may have an script behind but that another thing ) so now web apps like amazon, and yes stackoverflow don't show an file in the URL but anything comming is processed by the app in the server side.
websites urls without file extension?
Here I questions represents the webapp and 322747 the parameter
I hope this little explanation helps you to understand better all the other answers.
Well how about a having an index.html file in the directory and then you type the path into the browser? I see that my Firefox and IE7 both put the trailing slash in automatically, I don't have to type it. This is more suited to people like me that do not think every single url on earth should invoke php, perl, cgi and 10,000 other applications just in order to sent a few kilobytes of data.
A lot of people are using an more "RESTful" type architecture... or at least, REST-looking URLs.
This site (StackOverflow) dosn't show a file extension... it's using ASP.NET MVC.
Depending on the settings of your server you can use (or not) any extension you want. You could even set extensions to be ".JamesRocks" but it won't be very helpful :)
Anyways just in case you're new to web programming all that gibberish on the end there are arguments to a GET operation, and not the page's extension.
A number of posts have mentioned this, and I'll weigh in. It absolutely is a URL rewriting system, and a number of platforms have ways to implement this.
I've worked for a few larger ecommerce sites, and it is now a very important part of the web presence, and offers a number of advantages.
I would recommend taking the technology you want to work with, and researching samples of the URL rewriting mechanism for that platform. For .NET, for example, there google 'asp.net url rewriting' or use an add-on framework like MVC, which does this functionality out of the box.
In Django (a web application framework for python), you design the URLs yourself, independent of any file name, or even any path on the server for that matter.
You just say something like "I want /news/<number>/ urls to be handled by this function"