Adding a trailing slash to all URLs through IIS URL Rewrite Module is widely spread, but how do I add exceptions for URLs that ends with .html and .aspx?
Today I have this:
Charles46.2k1212 gold badges8989 silver badges127127 bronze badges
Seb NilssonSeb Nilsson14.3k2929 gold badges8585 silver badges115115 bronze badges
5 Answers
If you want something done right, you've got to do it yourself, obviously..
Here is the solution to my question:
Update: I blogged about this in more detail.
Seb NilssonSeb Nilsson14.3k2929 gold badges8585 silver badges115115 bronze badges
Varying the other answers, I used this so I wouldn't have to specify a list of file extensions:
Giscard BiambyGiscard Biamby
DenisDenis1,69233 gold badges1414 silver badges1919 bronze badges
To prevent all files from having a slash added, I changed the match rule to this:
That applies the rule only to paths that include any number of non-dot characters that does not end in a slash. So any path that includes a dot (e.g. xxx.html, xxx.aspx, etc.) would be excluded without needing any additional negation rule.
Looking for the presence of a dot in the match rule allowed me to completely remove the condition rules that use match types IsFile and IsDirectory. Those match types are only allowed in distributed rules (web.config), not in the global rules (applicationHost.config), so I had been forced to replicate this rule for every site instead of applying it to all sites using a global rule. By modifying the regex in the match rule to exclude files and removing the IsFile and IsDirectory conditions, I was able to create a global rule instead of having multiple distributed rules.
Garland PopeGarland Pope2,82311 gold badge2020 silver badges1717 bronze badges
This almost worked for me. I had to change it to
Otherwise thanks for this!
Colin WisemanColin Wiseman
Not the answer you're looking for? Browse other questions tagged asp.netiisurl-rewritingurl-rewrite-module or ask your own question.
Does anyone know if Google will punish a site if the homepage (with or without the trailing slash) returns a 200 ok header response?
I have tested tons of sites using an online redirect checker (CNN, NY Times, FOX News, Wikipedia, etc..) and they all return 200 'ok' with or without the trailing slash.
I know all inner pages need to use one or the other, but it appears the homepage is an exception. What do you all think?
PS, I'm using URLRewrite in IIS7 to force www, lowercase, and remove trailing slashes. It seems the homepage is the only page not affected by the trailing slash rule.
Thanks!
EDITFor example, using this online tool: http://www.internetofficer.com/seo-tool/redirect-check/The following URLs are 'Direct Links'. Neither is a 301 redirect..http://www.wikipedia.orghttp://www.wikipedia.org/
Numerous other examples produce the same results.
EDIT 2Here is my URLRewrite code (web.config)
Joe Hakooz
Joe HakoozJoe Hakooz
2 Answers
Osu game pc. Ok, so here is the official answer from the Google Blog
And I quote..'Rest assured that for your root URL specifically, http://example.com is equivalent to http://example.com/ and can’t be redirected even if you’re Chuck Norris.'
So there you have it. The root URL is not only safe with or without a trailing slash, but it might even be impossible to 301 redirect one to the other.
Joe HakoozJoe Hakooz
I would advise maintaining a set style (using one or the other) to prevent directory confusion. There should be no difference on the SEO side whatsoever. Using 301 redirects may be an option in this case if you feel you require it.
Daniel LiDaniel Li12.8k55 gold badges3636 silver badges5757 bronze badges
Not the answer you're looking for? Browse other questions tagged url-rewritingseo or ask your own question.
I have:
Perm redirect simply 301 redirects to the new URL.
This rule is meant to redirect any URL with an uppercase char to the lower case one.
This however creates a redirect loop, any ideas why? The only rules running so far are:
Tom Gullen
Tom GullenTom Gullen34.9k7070 gold badges245245 silver badges412412 bronze badges
1 Answer
Orce Lowercase Url And Trailing Slashes Iis Asparagus
You can either modify the regular expression to exclude .ashx files (which might get extremely complicated) or create a new rule before this rule, that will catch URLs pointing to ashx files and redirect them to a lowercase version of the string.
Something like this might work (not tested):
It uses a lookahead rule to check if '.ashx' is part of the url and if the URL is uppercase. If yes, it redirects to the lowercase version of the same url.
magnatticmagnattic7,3401010 gold badges5454 silver badges105105 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.