I've a situation which I'm going nuts trying to fix.
I need to redirect anything in one folder to its new location at another folder.
Via htaccess, that is.
Site.com/event/ >>> Site.com/sub01/event/
For a slightly more in-depth explanation of what I'd done, just in case it's needed:
I had a wordpress installation (inside a subfolder resolving to the root of the domain).
I then moved that installation to a new folder as so:
Site.com/sub01 >>> Site.com/sub02
That second installation now resolves to the root with the original now resolving to its own folder.
I left behind one folder /event/ with over 6,000 posts. Which ends up no longer located where it once was since it no longer resolves to the root. Follow?
Thus the reason behind needing the redirect. So that SE or actual person looking for that old address can still find it.
BTW, I've tried all sorts of code I'd found online...none of which worked. :(
====================
In response to Amit's question below,
Thanks for the reply Amit,
I've tried the following codes:
RewriteRule ^event/(.*)$ /sub01/event/$1 [L,NC,R=302]
RewriteRule ^event/(.*)$ /sub01/event/$1 [R=301,NC,L]
RewriteRule ^/event/ /sub01/event/ [R=301,L]
Mind you I've no clue what I'm doing in as far as this code's concerned.
Merely answers I found to other folks' similar questions.
As for what didn't work? Well, nothing changed at all except for simply, a page not found.
Thanks in advance to anyone with any input and insight.
Okay, I finally came across the answer.
It came through the use of Cpanel's Redirect Tool. I had no idea that solutions created that way are reflected through the htaccess found at the root of the domain.
But even that didn't work until I took the instructions inserted by Cpanel and moved them above all other instructions within the htaccess file.
Thanks folks for putting up with my ignorance in posting properly on this site.
Cheers! :)
Related
I'm having a weird redirection issue and can't figure out how to solve it. I installed my Wordpress in a directory (called /Cafe/ ) for my KatsCafe.org website and all the posts are being redirected just fine. But a huge number of my images are messed up. They won't redirect without the /Cafe/ in the URL, while none of my older URLs for images included a directory. My site is graphic/image heavy and many of them show up in Google Image searches so I am losing a lot of traffic over this.
I can't figure out how to redirect from two separate file paths to the current one.
My oldest file path was from when I installed Wordpress in the root directory with a previous host, so image from that installation would have the file path:
Http://katscafe.org/wp-content/uploads/year/month/name-of-file
to the current image file path, which would be:
Http://katscafe.org/Cafe/wp-content/uploads/year/month/name-of-file
I have another less important redirection I am having a few errors from as well, stemming from the short while I tried out a multisite option (silly me, I thought I would enjoy not having to handle updates, etc ... but I'm entirely too OCD to enjoy that, LOL). Since that meant that my files were in a multi-site directory listing, the file path would have been:
Http://katscafe.org/files/year/month/name-of-file
and still needs to forward to the current image file path, which again, is:
Http://katscafe.org/Cafe/wp-content/uploads/year/month/name-of-file
I'm not sure if I am overlooking an obvious tool that can help me figure this out, but every tool I've found involves post redirection, not a file path type of redirection. And even then I'm not entirely sure of my ability to figure it out completely.
I would be forever grateful for any help with this! Thanks so much!
Apologies for asking what is likely be a configuration related question, but I've been asked to fix this and have exactly Math.Sqrt(Jack_all) idea on how to fix it.
I can see on the main page that links to the CSS are correctly being requested as
http://www.digitalsignageexperts.co.uk/modules/system/system-menus.css?O
but when we look at a case study, linked from the main page the CSS requests are
http://www.digitalsignageexperts.co.uk/node/modules/system/system-menus.css?O
The path /node/ is creeping in from somewhere!
(In this instance the case study uri was http://www.digitalsignageexperts.co.uk/node/51)
Any helpful advice would be appreciated, thank you.
Check your .htaccess file. Better putting a fresh .htaccess file downloaded from drupal.org.
If nothing changed, try uncommenting RewriteBase / in .htaccess file.
I'm not suggesting $base_url because you said it didn't work in comments above.
This seems like it should be simplpe so if someone has a link that answers this I'll be happen with that and if this should be posted somewhere else please let me know.
What I'm trying to do
I am trying to install Drupal in a sub folder, and just have it work in the sub folder.
www.example.com/drupal/ so when i go to www.example.com/drupal/ i'll see the install.
The issues
All I get is a blank white screen not
I have changed the .htaccess files
adding
RewriteBase /drupal
I have tried reinstalling everything but still just a blank white screen.
there is no .htaccess file in the root directory.
Any help or links would be appreciated, I have been looking for a step by step or common issues but all the links I found are about rewrite the .htaccees so the sub directory is the main site or moving a site live.
Thanks
Wow always something simple, the server was set with php4 I had to move it to another server.
this took me 2 days to notice this.
so if you have a white screen make sure you check your php settings ;)
Could anyone please help me? I am at the last chance saloon and losing a lot of traffic. Any help would be greatfully received.
After a year based on my permalink structure, all posts were in the root so have been picked up by Google as:
snowmenu.com/postname
Since changing my categories and permalink structure, I need the years worth of posts on Google to be redirected to:
snowmenu.com/ski-snowboard-winter-sports-news/postname
Is there a way to make this happen via .htaccess?
Thank you very much to anyone who's able to help me.
Just had a look at the website and I am afraid from my knowledge their is no easy way to do this type of forwarding with .htaccess.
This is because there is no way to tell the difference in link structure from a "normal link" like (eg http://www.snowmenu.com/ski-resorts/) and what you want to be redirected to (eg http://www.snowmenu.com/ski-snowboard-winter-sports-news/latest-ski-news/). If you redirect all requests you will end up having links like http://www.snowmenu.com/ski-snowboard-winter-sports-news/ski-resorts/ which if I am right is not desirable?
The long solution would be to create a htaccess redirect for EVERY URL.
The only other solution that comes to mind is using PHP (or simular) to do a redirect within your 404 document.
EDIT
This will redirect ALL requests to the page you want. But as I said before I dont think this is what you want?
RewriteRule ^(?!ski-snowboard-winter-sports-news)(.*)$ /ski-snowboard-winter-sports-news/$1 [L,R=301]
EDIT 2
Having given it some thought I think I have have come up with a viable option. This will check to see if the requested file exists, if so it will redirect to your new directory (in theory :P).
RewriteCond %{DOCUMENT_ROOT}/ski-snowboard-winter-sports-news/$0 -f
RewriteRule ^(.*)$ /ski-snowboard-winter-sports-news/$1 [R=301,L]
You can use this plugin to avoid messing with .htaccess file directly:
http://wordpress.org/extend/plugins/redirection/
It has a nice interface for you to configure the redirection rules.
The plugin mentioned by #Wordpress Hardcore works best.
I moved a Wordpress website from one server to another and I am now getting 404 errors on everything but the home page.
I also checked that the .htaccess file is there and the database contents. They are fine. Not sure what else could be causing this.
Any ideas from the community?
Assuming you have pretty permalinks enabled, are you sure that the new server has mod-rewrite enabled? You can also check to see if this is the problem by going to a pagelike yoursite.com/?p=1 where 1 is a page id.
Assuming the URL has changed
You need to update either the database or (if you're lucky) one of the .php files in the wordpress distro - see the wordpress article on this.
I had the same issue and ended up having to edit the database. You're seeing the 404's because wordpress thinks it's still hosted at the old URL and is therefore trying to retrieve files from it.
If the URL has not changed
Perhaps permissions need updating on the folders? The folders should be set at 755 and the files 644 (reference here).
Looks like you may have solved the problem - I had a similar problem where permalinks would not work, but the default links did work. I modified the .htaccess file to what Wordpress said to do. Twice I thought I had solved the problem, but didn't.
I had moved it to my local Ubuntu Karmic Koala system for testing, and found that the solution involved editing a file in /etc/apache2/sites-enabled. On my system, it was called 000-default.
This file had statements like the .htaccess file, and in two places had AllowOverride None, which I had to change to AllowOverride All. Apparently, this file overrides any local .htaccess files.
I also had to change the location of Wordpress in the main configuration, but that was obvious.
I hope this will help someone who has tried all the normal suggestions like me, and is still having problems.