0

1st off I know about the redirect add-ons, but I need to do this in my .htaccess and not load any more on EE.

Before I found EE and started making EE sites. I used a free gallery program to create my gallery for my web site. Now I'm moving over the images to my EE built gallery.

Many thousands of images, no problem just htaccess it. For the most part old folders went to new posts. A few old galleries needed each picture sent to it's correct post entry.

After creating and testing all looked great, had to do a little more that I would have thought. Then I removed the old files and directories for the RewriteRule's I created.

Now I get my EE 404 and lost page notices.

Then if I recreated the directories, those would work. Then recreated empty html docs named the same as the previous html doc, and then those RewriteRule's worked.

I think if EE sees link to an actual folder it leaves it alone, but if no template for folder exists it serves 404.

(I have switchee checking segments and EE no post settings to verify all pages of my EE site)

But why is EE still serving something thats in the .htaccess

Could add some more to my 404 segment check. Rather not.

Or continue to create empty directories and empty same named html files for a fix, but why?

Before deleting the old files this is what I had to do to get all files and sub directories to redirect to new post entry.

RewriteRule gallery/Trees/(.+)?/?$ http://mydomain.com/entry/trees_and_plants [L,R=301]

But as of this moment I have to recreate every doc as an empty file named the same. But could there be a way to have EE ignore certain directories?

Thanks Mike

More info,

Basically after my rewrites, pages from my old gallery will be redirected to my new gallery. But as soon as I removed the old galleries files and directories my EE pick up on the bad pages and serves up my 404. right now having problems with gallery/Trees dir and pages.

Here is a shorten version of my htacces

RewriteEngine On 

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteBase /

RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC]

RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]

RedirectMatch 301 /forums/(.*) http://mydomain.com/NEW_forums/$1

RewriteCond %{QUERY_STRING} /forums/ 

RewriteRule (.*) http://mydomain.com/NEW_forums/? [R=301,L]

RewriteRule ^gallery/Trees/ http://mydomain.com/entry/lego_trees_and_plants [L,R=301]


deny from somedomain.com

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?otherdomain.com [NC]

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?otherdomain2.com [NC]

RewriteRule \.(jpg|jpeg|png|js|css|ldr|zip|lxf)$ http://mydomain.com/ask4_hotlink_mydomain_com.gif [NC,R,L]

##EE Spam Block

blah, blah, blah

##End EE Spam Block

1
  • I think if you gave more details about the paths that work, and that don't, we might be able to zero in on the issue. You might need to post ALL of your rewrites to make things fully clear, but please post at least all of the main rewrites that you think are affecting these URLs.
    – Jay F
    Jan 11, 2014 at 0:28

1 Answer 1

1

Here are a couple general things that might help:

I think the one RewriteRule you've posted could and should be simplified. From this:

RewriteRule gallery/Trees/(.+)?/?$ http://mydomain.com/entry/trees_and_plants [L,R=301]

To:

RewriteRule ^gallery/Trees/ http://mydomain.com/entry/trees_and_plants [L,R=301]

Then, here's a rewrite for EE to remove index.php that excludes the gallery/Trees path -- this should be your final rewrite block.

RewriteCond $1 !^gallery/Trees/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

If this doesn't help, please post more details about your rewrites, and I'll take another shot.

2
  • Thanks for your simpler code. I had tried that and a few other ways before I posted this question. But all gave same problem. I tried your finial rewrite but that did not change anything. As is unless I create files with the same name as all previous html doc and folders EE will serve my 404 page. Also this old gallery was not part of EE and was just folders and html docs. New gallery is EE.
    – user2437
    Jan 15, 2014 at 22:06
  • @user2437 thanks for updating with your code. Try moving the EE rewrite block after the 301 redirects.
    – Jay F
    Jan 15, 2014 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.