 |
|

09-13-2004, 06:53 AM
|
 |
SEO
|
|
Join Date: Aug 2004
Posts: 183
|
|
|
301 file name with space?
Is it possible to 301 redirect a file name that includes a space as part of the name? I thought of putting in a hyphen or underscore, but then it would be a different name. I've finally uploaded my sister's new site (will put it up for a site review soon :=)), and redirected most of the pages, but she has a few that include spaces, and when I include them in my htaccess file, I start getting error messages.
The only other thing I can think of is to leave them where they are, in revised format, lnking to new site.
LaryL
who seems to have a penchant for coming up with weird arcane details to ask questions about and who will be advising her sister NOT to use spaces in file names in future
|

09-13-2004, 07:00 AM
|
 |
SEO
|
|
Join Date: Aug 2004
Location: Mobile, AL.
Posts: 298
|
|
|
This is a longshot (not sure if it works in redirects) but try sticking %20 in place of each space and see if it works. Again, that works for spaces in general, just not sure if it will work in a redirect.
|

09-13-2004, 11:01 AM
|
 |
SEO Junior and a half
|
|
Join Date: Aug 2004
Posts: 47
|
|
|
The %20 should work ok for a redirect.
Last edited by Greyth : 09-13-2004 at 11:04 AM.
|

09-13-2004, 07:15 PM
|
 |
SEO
|
|
Join Date: Aug 2004
Posts: 183
|
|
|
mobilebadboy, when I saw your post, I thought you were brilliant. I always think people who see things that are right under my nose but I'm too blind to see, are brilliant. That makes you brilliant too, Greyth, just a bit slower!
Only one problem - I've quinzillion checked for typos, but my redirects for those 3 pages are not working with %20 substituted for the space, though all my other links without spaces are redirecting as planned. Any other brilliant ideas out there?
LaryL
|

09-13-2004, 08:13 PM
|
 |
SEO Junior and a half
|
|
Join Date: Aug 2004
Posts: 47
|
|
|
I'll be damned, I would have bet money that it would have worked...
um... well this is a little more complicated, but if you are an asp guy, (or I assume php or other languages you could use as well) you could maybe do a custom 404 error page (or whatever error it shows) that gets the right page name from the querystring, then opens the file and spits the right contents out to the page...
Last edited by Greyth : 09-13-2004 at 08:15 PM.
|

09-13-2004, 09:12 PM
|
 |
SEO
|
|
Join Date: Aug 2004
Posts: 183
|
|
Quote:
|
Originally Posted by Greyth
I'll be damned, I would have bet money that it would have worked...
um... well this is a little more complicated, but if you are an asp guy, (or I assume php or other languages you could use as well) you could maybe do a custom 404 error page (or whatever error it shows) that gets the right page name from the querystring, then opens the file and spits the right contents out to the page...
|
I agree - I was kicking myself for missing the obvious and asking a dumb question when I saw the %20 response, and then when it didn't work was positive I must have made a typo, but it still ain't working.
I have done a wee bit of database stuff with asp, not so much a code person as getting Dreamweaver to set up the behind the scenes stuff for me. However I'm now on a unix server, and have never done anything with php, though starting to think it's time to learn.
It's not a crisis at the moment, as if anyone clicks on the links on the page, they are redirected into the new site, so everything still works. I should replace the page with the new layout, though, while I figure out a way to redirect it.
I think I've seen and probably saved some info about scripting to have custom 404 pages redirect to specific targets depending on the referring url, but doesn't this still give a 404 error? And from an SEO perspective, if it were, say, a spider that hit the page, which would be worse - the duplicate content or the 404 error?
It just keeps getting more convoluted. Too bad the %20 isn't working - it would have been such an elegantly simple solution - and it seemed so logical!
Thanks for the input.
LaryL,
still working on digesting CSS and SEO, now contemplating PHP for dessert in alphabet soup land
|

09-15-2004, 10:18 AM
|
 |
SEO
|
|
Join Date: Aug 2004
Posts: 183
|
|
I did the move to the new domain on Sunday, so I really want to clear up forwarding these files to their corresponding pages on the new domain. The main pages are forwarding with no problems. But it's a real estate site, and most of these problem filenames are addresses with spaces , i.e. 123 street.htm .
They are found by Google, Yahoo and MSN, including by searches in the last couple of days that have led into the old domain, but not yet the new domain. I have seen the googlebot, Yahoo slurp and msnbot hit some of these pages on the old domain since the move, but only msnbot hit any pages in the new domain. Some of the pages also seem to be getting bookmark hits.
It's not a huge big deal, but I don't want to waste what recognition these pages have, plus I want to learn how to do this stuff properly, because it's bound to come up again some day. And I know I can simply redirect the domain as a whole, but I'd really prefer to point each page to the equivalent relevant page in the new domain.
For some I now have two separate pages up, one in old domain and one in new domain - not identical, because new pages have had code, titles, metatags and some content editing, but a lot of it is duplicate stuff, so they are very similar, and that is a concern.
At this point, after more hours spent surfing, I've found a variety of options. They range from 404 pages to quotes to mod rewrites (perhaps this thread should be in a different forum). I'll post the details of each separately to make it easier to get feedback, and to avoid producing too long and convoluted a post (which this is already getting to be )
LaryL
|

09-15-2004, 11:01 AM
|
 |
SEO
|
|
Join Date: Aug 2004
Posts: 183
|
|
|
301 Redirect file names with spaces in .htaccess option 1:
Question - is there a difference between updating the .htaccess file using notepad and then uploading it, versus using the cpanel redirect page? Cpanel seems to use the word permanent as opposed to the numeric code 301, and same for temporary redirect.
Two additional things I have tried are:
a) using * as a wild card in cpanel - i.e. redirect *street.htm to new page, instead of 123 street.htm
Cpanel accepts the entry and I can see it, but when I go to my browser, I still get the old page even after refreshing several times. So this doesn't seem to work.
b) I read somewhere that using quotes around the filename might work. I have tried in cpanel using :
"123 street.htm" and also using "123%20street.htm"
Cpanel appears to accept the input, at least I get no error messages, but I cannot see these on the cpanel list of redirected pages, and again, when i go to the browser, no redirection is taking place.
Did I make an error in trying these, or are they simply incorrect? I haven't yet trried inputting them to my own .htaccess file and uploading instead of the cpanel redirects - would that make a difference?
Thanks for any answers.
LaryL
Last edited by LaryL : 09-15-2004 at 11:03 AM.
|

09-15-2004, 11:08 AM
|
 |
SEO
|
|
Join Date: Aug 2004
Posts: 183
|
|
301 Redirect file names with spaces in .htaccess option 2:
I found this at http://216.239.39.104/translate_c?&...23redirectmatch
RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
Questions:
1)My programming skills aren't up to interpreting code very well, so I need a bit of syntax advice before I risk trying this. Would I write it as :
"RedirectMatch (.*street)\.htm$ http://www.newdomain.ca/newpage.html
Also, this code doesn't specify 301 redirect, so would the search engines understand that the page had been permanently moved?
Thanks, and more options coming,
LaryL
|

09-15-2004, 11:26 AM
|
 |
SEO
|
|
Join Date: Aug 2004
Posts: 183
|
|
301 Redirect file names with spaces in .htaccess option 3:
I found the following code to get rid of spaces in file names at
http://www.sitepoint.com/forums/showthread.php?p=1398137#post1398137
Options +FollowSymlinks
RewriteEngine on
# Does the URI contain a space ?
RewriteCond %{REQUEST_URI} ^(.*)\ (.*)$
# Yes, then replace it with an underscore
# The enviroment variable space_replacer will contain
# the new URI with a space replaced by an underscore
# A note from pippo:
# ``mod_rewrite'' will replace the space once at a time
# so if you have 10 spaces then mod_rewrite will make 10 internal
# redirections
RewriteRule ^.*$ %1_%2 [E=space_replacer:%1_%2]
# Is the enviroment variable space_replacer not empty ?
# (it means that we replaced a space with an underscore)
RewriteCond %{ENV:space_replacer} !^$
# Yes, but does the env variable not contain a space ?
# (it means that all spaces were replaced by an underscore)
RewriteCond %{ENV:space_replacer} !^.*\ .*$
# yay, finally it's time to make an external redirection
RewriteRule ^.*$ %{ENV:space_replacer} [R=301,L]
# Original part
# if the URI doesn't contain a dot and doesn't contain a slash
# then make an internal redirection to the file with the .shtml
RewriteRule ^([^./]+)/?$ $1.shtml [L]
For my problem, where his comment says "#yay, finally time to make an external redirection", would I then have converted all my spaced files to files with underscores so that I could follow this portion of the script with regular 301 redirects on the new names?
Example:
123 street.htm now 123_street.htm
234 ave.htm now 234_ave.htm
345 road.htm now 345_road.htm
so my script would look like:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*)\ (.*)$
RewriteRule ^.*$ %1_%2 [E=space_replacer:%1_%2]
RewriteCond %{ENV:space_replacer} !^$
RewriteCond %{ENV:space_replacer} !^.*\ .*$
redirect 301 /123_street.htm http://www.newdomain.ca/123newpage.html
redirect 301 /234_ave.htm http://www.newdomain.ca/234newpage.html
redirect 301 /345_road.htm http://www.newdomain.ca/345newpage.html
Hoping this all makes sense to someone out there!
LaryL
|
 |
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|