0

I moved my site to a new hoster. Everything works fine (Images path's js css templates, all fine).

I adjusted all path's with Reelocate. But all the Link in the Navigation throw back this error message:

Not Found
The requested URL /subdirectory/segment_1/entry was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

It must have something to do with the subdirectory

In the webroot I have a .htaccess with this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /subdirectory/$1 [PT,L,QSA]

and then in /subdirectory I have this .htaccess

# Removes index.php from ExpressionEngine URLs
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

# Remove www.
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [L,R=301]

RewriteEngine off

Do I miss something?

Thank you


Edit:

The sollution of Alexa Lohmeyer worked. Here is how it looks if anybody is intrested:

One main error was that I had RewriteEngine off which somehow even disabled removing index.php.

So the root .htaccess looks like this:

RewriteEngine on

#Remove www
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

#Hosting directive for pointing url to subfolder
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^(.*)$ /subdirectory/$1 [PT,L,QSA]

And then in the .htaccess of the subdirectory it looks like this:

# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

# Removes subdirectory from url string
RewriteRule ^subdirectory/index.php?(.*)$ /$1 [L]
  • Does it really have the words segment_1 in the path or is that just a placeholder? It the path is really /subdirectory/segment_1/entry then to me it would look like EE isn't replacing your segment variables. – Adam Christianson Aug 6 '13 at 13:30
  • Your website was in a subdirectory before moving? – Robson Sobral Aug 6 '13 at 14:19
  • No segment_1 is just the variable. I is beeing replaced correctly. Before moving, the website wasn't in a subdirectory. Unfortunately my hoster doesn't allow my main domain to point directly into the subfolder. I have to do it via .htaccess. – KSPR Aug 6 '13 at 15:04
  • Okay. The url doesn't work because of the removal of index.php if I add /subdirectory/index.php the links work. Is it possible to also remove the subdirectory and not just index.php? – KSPR Aug 6 '13 at 16:38
1
RewriteRule ^subdirectory/index.php(.*)$ /$1 [L]

This should rewrite your original url:

http://domain.com/subdirectory/index.php/segment_1/entry

as:

http://domain.com/segment_1/entry

If that doesn't work, are you able to move your .htaccess into the root of your site directory? Or does it have to stay in your subdirectory?

Here is a handy htaccess test site: http://htaccess.madewithlove.be/

| improve this answer | |
  • Thanks. This handy .htaccess tester does output the url I want but it still doesn't work on my server. No matter if the rule is in the root .htaccess or not. Not even the standard index.php removal work on this server :( – KSPR Aug 7 '13 at 6:59
0

How to remove index.php in ExpressionEngine site from iPage hosting

https://emineysprince.com/technology-tips/post/how-to-remove-index-php-in-expressionengine-site-from-ipage-hosting

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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