.aspx pages redirected but not .html - iis

We switched our website from a custom .NET solution to a Wordpress site. As a result, I have needed to write a couple specific URL Rewrite rules in IIS to 301 redirect old urls to their equivalent pages in the Wordpress site. Considering the following 2 rules, rule 1 will match and redirect properly. However, rule 2 won't. My question is, why doesn't the rule 2 work? The only difference seems to be .html vice .aspx.
Rule 1
Pattern:
our-company/our-staff.aspx
URL:
http://www.ourdomain.com/our-company/our-staff.aspx
Rule 2
Pattern
labs/some-file.html
URL:
http://www.ourdomain.com/labs/some-file.html

Related

web.config redirect "index.php" pattern to home page of domain

I have a few bots crawling my sites for very old pages (when I used joomla as CMS), so every index.php/... now generates a 404 in log.
I'm trying to create a redirect rule in web.config so that all links that relate to index.php... will now be redirected to the root domain. There are 4 domains pointing to this site, so it needs to redirect to the proper domain.
As examples:
site1.com/index.php?something needs to redirect to site1.com
site2.com/index.php/alsosomething need to redirect to site2.com
I have URL Rewrite module in IIS, so I just need to create the rule, but I can't figure the patterns.
Any help is appreciated. Thanks.

htaccess Redirect URL of Subdirectories managed through CMS

All the urls of our site are written www.mydomain.com/sub1/cms/pagename
Through the CMS we can specify pagename
sub1 and cms are not actually directories on the server.
We need to change the pagenames to be more SEO friendly, but we still want any traffic to the old pagename to direct to the new one.
I have tried making an .htaccess file specifying:
Redirect 301 /sub1/cms/oldpagename mydomain.com/sub1/cms/newpagename
but it does not work.
I have been successful with:
Redirect 301 /oldpagename mydomain.com/sub1/cms/newpagename
Can this be done somehow through .htaccess?
First, make sure your 301 redirect rules for redirect use a full url including the http:// portion.
Redirect 301 /sub1/cms/oldpagename http://mydomain.com/sub1/cms/newpagename
Second, it sounds to me like your CMS has put a rewrite rule in place to handle the /sub1/cms/pagename style urls. If this rule comes before your redirect, your redirect will never get triggered. Try moving your redirect to the top of the .htaccess file.

How to remove part of URL .htaccess - Magento

I need to remove the last two sections [/../..] of any URL requests that include [/desc/name-of-product] via .htaccess.
Example:
[www.domain.com/product.php/id/10101/desc/apple-laptop-computer] ->
[www.domain.com/product.php/id/10101]
[www.domain.com/product.php/id/985/desc/hp-computer] ->
[www.domain.com/product.php/id/985]
I am working on a Magento site that currently redirects old URLs (Example: www.domain.com/product.php/id/10101 to the new Magento URL www.domain.com/product-name via the URL Rewrite Management tool in Magento. The problem is the old domain was allowing Google to crawl two URLs for the same product in the examples above.
Since Magento is rewriting the shorter URL in the example above properly, I need a rewrite rule to remove the last two sections [/desc/name-of-product] of any incoming links that have a [/desc/*] section.
RewriteEngine on
RewriteBase /
RewriteRule ^/product.php/id/(\d+)/desc/[^/]+$ /product.php/id/$1 [R=301]
This will do an HTTP 301 redirect to your new URL, so Google will be informed that the page has moved permanently.
More informations on the Apache rewrite mod
List of HTTP status codes

mod_rewrite in .htaccess to replace .aspx

I have converted a website from ASP to php...and the urls no longer require an extension. I want to strip off ".aspx" from the end of my incoming strings (from search engines for example) and then 302 redirect them to the correct page without that extension so that the rest of my mod_rewrite rules can then take over. How would I do this?
OLD URL: www.mysite.com/test/page/here.aspx
NEW URL: www.mysite.com/test/page/here/
Thanks!
Place this rule into your .htaccess file in root folder (before catch-all rewrite rule, if you have such):
RewriteRule ^(.+)\.aspx$ http://www.example.com/$1/ [QSA,NC,R=301,L]
This will redirect http://www.example.com/test/page/here.aspx to http://www.example.com/test/page/here/.
Please note, it is better (at least from SEO/browser point of view) to have 301 redirect code (Permanent Redirect) instead of 302 (Found/Temporal Redirect). Unless you may consider changing website back to aspx.

Trouble redirecting all pages in a folder to a page at root level

I've searched, tried various examples, and none, other than creating an explicit list of redirect statements seems to work.
The biggest issue I have is that, although I have access to deploy web pages to the site, I do not have access to any web hosting control panel - site access was inherited, and until now it's been fine, but I think that it is either running an old version of apache, or rewrite rules are not allowed.
Anywa, over the years, the site has changed several times, and after registering the site with Google Webtools, I found the list of pages that gave crawl errors, so created an HTACCESS file to deal with these.
Over the years, there have been folders deployed and named in camel case and all lower case, and so all I wanted to do was to redirect all files in a folder to the new folder in the .htaccess file level, i.e.
My .HTACCESS currently has 120 lines, and an example batch are as follows:
redirect 301 /challenge/stanley_steamer.htm /lsr_history.html
redirect 301 /challenge/stanley_steamer.html /lsr_history.html
redirect 301 /Challenge/index.htm /lsr_history.html
redirect 301 /Challenge/Record.htm /lsr_history.html
redirect 301 /Challenge/Stanley_Steamer.htm /lsr_history.html
redirect 301 /Challenge/Sponsors/Avery_Weigh-Tronix.htm /sponsors.html
redirect 301 /contact/index.html /contact.html
redirect 301 /design/details.html /design.html
redirect 301 /design/index.html /design.html
redirect 301 /Design/Engine-drive_train.htm /design.html
redirect 301 /Design/Rear.htm /design.html
redirect 301 /Design/Home_Page.htm /design.html
redirect 301 /Design/index.htm /design.html
As you can see, I have some cases where the folder name is camel, others lower, and other cases where there is a htm and an html file of the same name that is listed in the crawl error log.
All I want to do is, in the example above, redirect all pages from /Challenge/ and /challenge/ to lsr_history.html, but all files in /Challenge/Sponsors/ to sponsors.html.
I also have a huge list of individual team pages that I list one by one and each one redirects to the new team page.
I've tried examples like:
RedirectMatch 301 ^/[Cc]hallenge/ /challenge.html, but this returns a 'Error 404 Not found'.
Any ideas or examples of how I can cut down my htaccess file to simplify this will be gratefully received.
Regards
Martin
I wouldn't bother searching for cases inside the match string for this kind of thing if I could avoid it - have you tried just specifying the RedirectMatch in lowercase, and appending [NC] to the end of every line? (that will tell mod_rewrite to ignore case and match regardless, which may save you some time)
if you have collections of similarly-formatted rewrites, why not group them together with one particular set of rules for each? That way you could cover, for example, all incoming URLs with one subdirectory with one rule, and all incoming URLs with a single subdirectory one with another rule. If nothing else, it could help simplify viewing the .htaccess file :)
(Take everything I suggest with a massive dose of salt, I'm still getting to grips with the black magick of mod_rewrite myself)

Resources