Web config redirects not working where a trailing slash is involved
-
I'm having real trouble with getting working redirects in place to use on a site we're re-launching with a modified url structure.
Old URL: http://www.example.com/example_folder/
New URL: http://www.example.com/example-of-new-folder/
Now, where the old URL's have a trailing slash the web.config simply will not accept it. It says the URL can start with a slash, but not end with a slash. However, many of my URL's do end with a slash so I need a workaround.
These are the rules I'm putting in place:
<location path="example_folder/"></location>
Thanks
-
That works perfectly, thank you very much
-
The following will work for both slash and no slash,
<rule name="Test" stopprocessing="true"><match url="^example_folder"><action type="Redirect" url="/newfolder"></action></match></rule>
if not sure where to place it, see link in last post, bottom of page
-
Thanks for the response Alan.
However, the problem is with the old URL's, so where they have a trailing slash I cannot get them to redirect to any URL's of the new structure (with a trailing slash or otherwise.).
To simplify the ask, how do I put in place a 301 redirect from 'http://www.example.com/example_folder/' to some other URL?
-
i would first decide if you want a slash or not. i prefer not as when people type urls they rarly add a slash on the end.
see this page will tell you how to remove all slashes and then your redirects should work
http://thatsit.com.au/seo/tutorials/how-to-fix-canonical-issues-involving-the-trailing-slash
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Add trailing slash after removing .html extention
My website is non www ,it has wordpress in subdirectory and some static webpages in the root and other subdirectory 1. i want to remove .html extention from the webpages in the root and
Technical SEO | | Uber_
the others static webpages in subdirectory.
2. add slash at the end.
3. 301 redirect from non slash to url with slash. so it should be http://ghadaalsaman.com/articles.html to http://ghadaalsaman.com/articles/ and http://ghadaalsaman.com/en/poem-list.html to http://ghadaalsaman.com/en/poem-list/ the below code 1. working with non slash at the end **2. **redirect 301 url with slash to non here's my .htaccess <ifmodule mod_rewrite.c="">Options +FollowSymLinks -MultiViews RewriteEngine On
RewriteBase /</ifmodule> #removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L] #www to non
RewriteCond %{HTTP_HOST} ^www.(([a-z0-9_]+.)?domain.com)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L] #html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [NC,L] #index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ http://ghadaalsaman.com/ [R=301,L]
RewriteCond %{THE_REQUEST} .html
RewriteRule ^(.*).html$ /$1 [R=301,L] PS everything is ok with the wordpress , the problems with static pages only. Thanks in advanced0 -
Max Number of 301 Redirections?
Hi, We currently made a re-design of a website and we changed all our urls to make them shorter. I made more than 300 permanent redirections but plenty more are needed since WMT is showing some more 404s from old urls that I hadn't seen because they were dynamic. The question is, please, is there a limit? I think we have more than 600 already. We don't want to create a php commando to redirect all the old ones to our home, we are redirecting them to their correspondent url. By the way, Im doing them with the 301 method in .htaccess. Thanks in advance.
Technical SEO | | Tintanus0 -
301 Redirect
Hello, On the 26.2.13 we changed domain names having followed the guidance of both Matt Cutts Youtube videos and googles own online documentation. We have a 301 redirect in place from our old domain ukmotorhomehirerental.com to our new site leisurerentalsdirect.com on a page to page basis. The site structure has not been altered in anyway. Google has been informed of the change of address. After the change the new domain transition was pretty seamless and ranked in the same postion in the SERPsThe one thing I've not done yet is tell all the webmasters who link to the old site that the address has changed (could this be it?)
Technical SEO | | Badapplemedia0 -
Apache redirects
Hey all I'm handling some redirects and am fuzzy with Apache server stuff. I'm redirecting dynamic URLs and the only thing that's changing is the new domain. I have implemented this in the server file (thus far unsuccessfully): RewriteEngine on
Technical SEO | | jamesm5i
RewriteCond %{HTTP_HOST} ^.oldsite.com$ [NC]
RewriteRule ^(.)$ http://www.newsite.com/$ [L,R=301] Any ideas on what I can change to make it work? For those who are more familiar I know I'm missing something simple. Thanks as always!0 -
301 Redirect Have no ranking
Hi Guys wonder if you can help my site www.economy-car-leasing.co.uk has just been 301 from www.economyleasinguk.co.uk The reason for the move is the site is going to be structured for both cars and vans separately we did the 301 around 8 weeks ago and initially we thought everything went well, all the new site was indexed within 24 hours, we updated WMT on the old site we monitored around 150 keywords many were top 10 in Google 99% were top 5 pages However 8 weeks on we do not rank for hardly anything, i have confirmed all the redirects are working, we have 200 ok from the home page and all the other canonical pages return 301 we just implemented the canonical tag to all pages. we did factor that we will get some down time but not 8 weeks worth, i have done a 301 on this scale before with no real loss of rankings (Different site) Really tempted to put the old site back however its not what i want to do, Bing seems to have picked up on the change really well but im thinking Google just needs time The change looks like its done perfectly and everything is working as it should however it looks like that none of the original rankings or juice has been pushed over from Google yet and im wondering how long does it typically take to get the site ranking again site have gone from 17k unique s per month to less than 2k Paul
Technical SEO | | kellymandingo0 -
Can I redirect a URL that has a # in it? How?
Hi there - My web developer is saying that I can't do a URL redirect with a "#" in it. Currently, the URL is actually an anchored link within a page (which the URL indicates with a #). I want to change the content to a new URL, but our website links internally to the old URL, so we would need to do a URL redirect (assume 301). Can you tell me if this is possible and how? Thanks!
Technical SEO | | sfecommerce0 -
I Need advice in redirecting domains
I have tow domains (destination/town - travel websites), www.gansbaai.com, and www.danger-point-peninsula.co.za. The one, gansbaai.com is an old domain I bought under which I will be launching a new website in a couple of months. danger-point-peninsula.co.za, is another domain I acquired also about gansbaai, the area. I will we using the domain gansbaai.cm, but want to get the best link juice out of danger-point-peninsula. How do I merge the domains?
Technical SEO | | DROIDSTERS0 -
Are asp redirects permanent?
I need to redirect a windows-hosted domain with permanent (301) redirects so as to preserve most of the link juice. I would be using asp page-level redirects, as there are only about 50 relevant pages. Are these as effective as linux-based 301 redirects in conserving link juice?
Technical SEO | | waynekolenchuk0