Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Jun 13, 2013 8:35 pm 
Offline
Junior Member

Joined: Mon Mar 29, 2010 3:11 pm
Posts: 48
Website: http://www.tamerax.com
Location: Montreal, Quebec
The wordpress site I'm working got moved into a subdirectory therefore all the links from other sites don't work anymore. I implemented a 301 redirect with htaccess which is great because it fixes that problem BUT the old root directory now has an index.html that has landing page my client absolutely wants to be seen.

So, how can I set up my htaccess to redirect all traffic into the sub directory (to fix the incoming links) EXCEPT the index.html in the root directory because it has the landing page.

I don't know how htaccess works well but this is what I have right now.
Code:
Order deny,allow
ErrorDocument 404 /404.php
DirectoryIndex index.php index.html

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$ [OR]
RewriteRule ^.*$ http://example.com/portal/$0 [R=301,L]

So to recap:

Right now EVERYTHING redirects from the root to the subdirectory. I want everything to redirect EXCEPT for index.html in the root directory because it's a landing page.


Thanks!!


Top
   
PostPosted: Fri Jun 14, 2013 9:02 am 
Offline
Senior Member

Joined: Mon Jan 02, 2012 12:45 pm
Posts: 365
Would this do it?
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$ [OR]
# this should only grab the root dir's index.html and ignore index.html in subdirectories
RewriteCond %{SCRIPT_URI} !^example.com/index.html$
RewriteRule ^(.*)$ http://example.com/portal/$1 [R=301,L]


MSJ


Top
   
PostPosted: Fri Jun 14, 2013 2:43 pm 
Offline
Junior Member

Joined: Mon Mar 29, 2010 3:11 pm
Posts: 48
Website: http://www.tamerax.com
Location: Montreal, Quebec
thanks for that but unfortunatly it just forwards everything right to portal still.

this so far is best I have:
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index\.(php|html) [NC]
RewriteRule ^.*$ http://example.com/portal/$0 [R=301,L]


but it only works if i specifically write example.com/index.html

It's the only file in there and the irectoryIndex index.html is set but if i just go to the root with nothing else in the url, it forwards me to /portal/

So, I'm close? hahaha. any thoughts?


Top
   
PostPosted: Fri Jun 14, 2013 4:13 pm 
Offline
Senior Newbie

Joined: Sat Oct 01, 2011 10:06 am
Posts: 5
Location: Massachusetts, USA
So if I understand right, you want to redirect everything (except index.php&index.html) from http://example.com/ to http://example.com/portal.

try following:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteCond %{REQUEST_URI} !^/index\.(php|html)$ [NC]
RewriteRule ^(.*)$ http://example.com/portal/$1 [R=301,L]


besides, you said you are using wordpress, so I assume you removed previous rewrite entries for wordpress in your root directory.

Tamerax wrote:
thanks for that but unfortunatly it just forwards everything right to portal still.

this so far is best I have:
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index\.(php|html) [NC]
RewriteRule ^.*$ http://example.com/portal/$0 [R=301,L]


but it only works if i specifically write example.com/index.html

It's the only file in there and the irectoryIndex index.html is set but if i just go to the root with nothing else in the url, it forwards me to /portal/

So, I'm close? hahaha. any thoughts?


Top
   
PostPosted: Fri Jun 14, 2013 4:29 pm 
Offline
Junior Member

Joined: Mon Mar 29, 2010 3:11 pm
Posts: 48
Website: http://www.tamerax.com
Location: Montreal, Quebec
That is exactly what I want. Unfortunately, that bit of code doesn't work unless I specify the index.html like before. Still forwards on anything else.

And yes, the directory is empty except for the htaccess file, the index.html and the subdirectory folder.


Top
   
PostPosted: Sat Jun 15, 2013 8:12 pm 
Offline
Junior Member

Joined: Mon Mar 29, 2010 3:11 pm
Posts: 48
Website: http://www.tamerax.com
Location: Montreal, Quebec
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index\.(php|html) [NC]
RewriteCond %{REQUEST_URI} !^/$ {NC]
RewriteRule ^.*$ http://example.com/portal/$0 [R=301,L]


Still not working. everything is forwarding to /portal/ unless it has it specifically written index.html


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group