I think my question may be worded incorrectly but heres what I want to do (for SEO purposes).
I have a page that gives a logo and description of a brand e.g. Volvo. I want to use this same page as a template for all manufacturers but just change a few words around to customize it for each manufacturer accordingly. So in the URL I pass it a variable of the manufacturer e.g. "www.example.com/cars.cfm?manufacturer=BMW" and it will show a page that gives information about BMW.
The problem is that for each manufacturer the information is still showing up as the same page "cars.cfm" in the address bar but really I want it to go to a URL like "www.example.com/manufacturers/volvo.cfm" so it appears as a unique page just for that brand. But at the same time I don't want to have to create a seperate CFM (or php/asp) page for each manufacturer.
Is there a clever way to do this at all? I imagine its something to do with URL rewriting but not sure. I am using IIS 7.5.
Creating numerous sub-folders for different car manufacturers is going to be very tedious. My site would also include other types of manufacturers for different products not just cars. I guess URL rewriting would be best but my idea was to have a different 'page' for each manufacturer so the SEO would be improved.
Basically....
www.example.com/manufacturers/audi.cfm
www.example.com/manufacturers/bmw.cfm
www.example.com/manufactueres/volkswagen.cfm
But really I want the data on each of those pages to come from a database which contains unique data for each manufacturer such the logo image and history description.
Here is an example of what I mean:
http://www.fivestarautocentre.co.uk <-- go to bottom of that page and you can see links to various manufacturers
Building on what everyone else said, start by creating your www.example.com/cars.cfm?manufacturer=BMW page and get that working.
Assuming you're on IIS you would then create a web.config file (if it isn't already there) in your root folder.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Cars-Rewrite">
<match url="manufacturer/(\w+)" />
<action type="Rewrite" url="/cars.cfm?manufacturer={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
My regex could be off, but maybe someone else could chime in with the correct regex.
You can certainly handle this with URL rewriting as others have suggested but I think I would take a different approach. Particularly for SEO purposes. The best solution for SEO will be an actual URL for each brand. With that in mind create your site accordingly. Don't use a generic www.example.com/cars.cfm page, use www.example.com/bmw, www.example.com/volvo, etc. You can still have a ColdFusion page under each of those folders that does nothing more than include your generic ColdFusion template from another location (or call a cfc). Since each folder will have it's own unique stub file you can pass the appropriate vehicle manufacturer when the generic ColdFusion template is called. For example, under the www.example.com/bmw page:
<cfset manufacturer = "bmw" />
<cfinclude template="/mytemplates/genericpage.cfm" />
Then your genericpage.cfm uses the assigned variable to display the appropriate text and graphics. You could even get around having to set a particular variable under each folder by parsing the URL and grabbing the manufacturer from it when the template is included and executed. I believe the cgi.script_name variable will contain the path needed to do this.
Related
Please bear with me because I am very new to Umbraco.
I have a test Umbraco config file that looks like the following:
<Product nodeName="For-test">
<customId>222/</customId>
</Product>
<Product nodeName="For-none">
<customId>333/</customId>
</Product>
In my test.master page, I would only like to match the child element who's parent has the value of "For-test". This should give me the value of "222". I am using the following code to display the element values but I get the following error "Error loading MacroEngine script (file: )" I believe that my syntax is wrong.
<umbraco:Macro runat="server" language="cshtml">
#Model.nodeName="For-test".customId;
</umbraco:Macro>
Which Umbraco version are you using? Version 7 is best when using MVC, so you wouldn't typically have a master page at all.
Also, you shouldn't have to be fiddling with umbraco.config at all.
I would suggest you start by installing the starter kit (maybe in a fresh install?), then you can check out how "it" does things. Also, have a good look in the documentation (https://our.umbraco.org/documentation/) and maybe even check out some of the video tutorials (something like these http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/).
As for your specific question:
No need to use the <umbraco:Macro /> tag - but since you are in a Web Forms type website (and not MVC), you can't use # to indicate code sections. You'll have to try with <%= %>.
The Umbraco Model is tied to whatever page you are viewing. You can query for content by Id or "nodeTypeAlias" (which in your case would be "Product", and you'd get all Products at once), but not easily by name since it isn't unique.
But I think you can get a much better grasp of how things are done in Umbraco by looking at the links provided above.
For a detailed error go to App_Data/Logs/ and open the newest .txt file.
This is my first time round using Umbraco and I have created Document Types / Pages using the wrong naming format and now this has transpired into my page URL's, for instance /about-page/. How would I go about changing them to /about as I have searched the back-end admin panel and there dose't seem to be an option to change their link to document values.
Would anyone be able to provide a simple code based example using umbracoUrlAlias or umbracoUrlName how I could change this preferably in Razor.
Thanks
Editing #run yards Solution by digbyswift help in comment
Correct Solution:
Create Property on in Document Types which applies to all pages you want to change the URL
Call the name anything you want e.g Page URL and Possibly give it a new tab.
Call the alias umbracoUrlName
Type as text sting
Should not be Mandatory (As when you start replacing .Url with .umbracoUrlAlias within the views it will need to be present)
Tab as Generic
Click Save on top right on the page
Added screenshot for starter kit on Umbraco v7.2.5
Unless I'm very much misunderstanding your issue, you should just be able to change the name of your page and republish. This doesn't need an additional field, just change the value in the "Properties" tab and republish the page. This will automatically change the URL of the page.
You can also create a property called umbracoUrlName using a TextString property editor. If this has a value then it will generate the URL fragment for the page using this value, rather than the page name. This changes the URL for the page, rather than creating an alias, like umbracoUrlAlias.
Solution:
Create property on in Document Types which applies to all pages you want to change the URL
Call the name anything you want e.g Page URL and Possibly give it a new tab.
Call the alias umbracoUrlAlias
Type as text sting
Make it required (As when you start replacing .Url with .umbracoUrlAlias within the views it will need to be present)
Go into all your pages and rename them using the property you just created
Now with your code, say with the navigation where you have used .Url change it to .umbracoUrlAlias and the new URL's will be used.
Note if you don't use .umbracoUrlAlias the links will still be active i.e. they work but they won't be displayed in the address bar as .Url spits out the original ones associated with the page.
You can apply on URL names in web.config:
In section find:
<add key="umbracoUseDirectoryUrls" value="false" />
this will set url names for new created items to name.aspx
If you set this to 'true' then new items will be named like /name/
Additionaly you might want to avoid of Handling some urls by Umbraco pipline, just use this setting - add URLs which must be bypassed:
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
Requesting a page from IIS (hosts ASP.NET MVC 3 site) with url containing web.config gives 404 error. Urls with app.config have no problem. Local Visual Studio development server has no issues with this type of urls.
1 - What are any other special words other than web.config, being handled this way by IIS?
In request filtering page/hidden segments tab this is the current state:
I guess these are not special words, because IIS handles words like bin, App_code etc without a problem.
Answer: I guess these are the words being handled by IIS this way. So these are the default words I think and this list is configurable (new items can be added to this list).
2 - Are there any quick fixes (like by web.config modification) to handle urls with these special words?
Btw, I am not trying to serve the web.config file. Url format is : www.mysite.com/es/web.config/1
This is part of the IIS configuration under the Request Filtering section:
You can add/remove filters.
However, I do believe this is a really bad idea to remove web.config from it.
http://www.iis.net/configreference/system.webserver/security/requestfiltering
Cause:
As you already shown a snapshot of IIS configuration. These are reserved folder & files in .Net application, so IIS want to preserve those for security.
URLs which contain these strings as returned as 404 response only if these comes in before ? AND exactly between 2 slashes /../ OR at last. Eg: www.example.com/bin/anything.ext OR www.example.com/folder/sub/web.config
IIS match these string anywhere coz, web.config can we at any directory level.
If anything is with those string are there THEN page will be served by IIS. Eg: www.example.com/bin-folder/anthing.ext OR www.example.com/sub/bin.html OR www.example.com/-web.confing/page.aspx are OK.
I recommend to use some other words with these strings OR use at end of URLs with extensions, so that it will not come between two slashes.
Eg: www.example.com/en-web.config/1 OR www.example.com/en/1/web.config.aspx
Even then I have one Tricky Solution:
If you really need these strings exactly without other words in URL THEN I recommend to use URL-ReWrite.. This may not be quick at whole but except 2nd step its quick and handy, coz second step depends on your application.
1- Add this rule in IIS at top level:
regexp match: (/web|^web)\.(config$|config/) //OR as your requirement
re-write to: handler.aspx?url={REQUEST_URI}
<rule name="web-config" stopProcessing="true">
<match url="(/web|^web)\.(config$|config/)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="handler.aspx?url={REQUEST_URI}" appendQueryString="false" />
</rule>
2- In handler.aspx (or in any other language page) check the url GET variable and respond accordingly.Request.QueryString("url")
Do it carefully coz here you are controlling security.
I suggest to include the actual page content to response in handler.aspx or handler.php only rather then redirecting etc.
Before including content verify URL first(by regular expression etc.), and include content hardcoded, do not take any part of URL in to variable and use that variable in response-inclusion-code.
3- After that at last from IIS manager, In a specific website go to request filtering->hidden segment tab and delete the desire string. Eg: web.config. This step can be done by web.config also:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="209715200" />
<hiddenSegments>
<remove segment="web.config" />
</hiddenSegments>
</requestFiltering>
</security>
Now, IIS will serve the page and your handler page will show the output with exact same URL in user browser.
Hello I created some page in Umbraco 4.7 CMS,
configure some alternative links to page(section) it looks like.
If I look at
Link to document
/folder/folder2/page1.aspx - workig
Alternative Links
http://site.com/folder/folder2/page1.aspx - workig
http://site.com/en/folder/folder2/page1.aspx - not working
http://site.com/old-folder/folder2/page1.aspx - not working
but in browser just /folder/folder2/page1.aspx show a valid page other links redirect users to 404 page that configured in umbraco config file.
Have you considered using the UrlRewriting module to get this working. You could add a new rule similar to the following:
<add name="page1rewrite"
virtualUrl="^~/en/folder/folder2/page1.aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/folder/folder2/page2.aspx"
ignoreCase="true" />
This could be further improved depending on your exact requirements but you could it you wanted rewrite all urls ~/en/folder/folder2/ to the new location.
An alternative option would be to use the umbracoUrlAlias document type property.
Visual Studio 2008
I want to bring some localisation into my ASP.NET MVC site.
Someone suggested creating a resource file "Strings.resx" as a publically strongly typed resource, which works nicely and allows me to write
<title><%= Strings.MyView_Title %></title>
I then proceeded to add a file "Strings.da.resx". This file is created right next to the first one, and defaults to "Access Modifier : No Compilation", whereas the first (the one without language modifier) defaulted to "Interal".
I can see in the bin directory that a directory has been created ("da") with a resource.dll, however, I cannot see any of the translated texts on my site.
I have checked with the browser that the only preferred langauge is Danish (da-DK), but I only see the english texts.
Questions:
1) Do I need to enable something in web.config ?
2) Am i creating the right files, with the correct types (i.e. should #2 be "No compilation") ?
In your views, do you have a page directive?
If so, do you have UICulture="Auto" and Culture="Auto"?
For example...
<%# Page Language="C#" Inherits="..."
culture="auto" uiculture="auto" %>
This will ensure that the Accept-Language header, passed by the browser in the request, gets used to set the Thread cultures. It's the UICulture that influences which resource file to pick.
For more on ASP.NET i18n this book is very good...
http://www.amazon.co.uk/NET-Internationalization-Developers-Guide-Building/dp/0321341384/ref=sr_1_1?ie=UTF8&s=books&qid=1241010151&sr=8-1
It doesn't cover MVC, but covers ASP.NET and, as such, many things continue to be relevant.
First you have to create action filter that will switch culture of request thread.
OR
Set your globalization element to UICulture="Auto" and Culture="Auto"
Check this screencast, it is in Russian but code samples are understandable.