Welcome to WebmasterWorld Guest from 34.229.194.198

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

301 redirect all except one directory

Can I do this?

     
6:36 pm on Sep 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member trillianjedi is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 15, 2003
posts:7256
votes: 3


I have one server not on WWW duty but requires example.com to point at it.

So I have example.com resolving to it's IP, and I need to redirect any web requests to the www box.

So far, easy.

Problem is that I need to access phpmyadmin on this box from time to time, so I do need access to example.com/phpmyadmin

Is there any way I can do a conditional 301?

So if the requested URL isn't /phpmyadminXYZ then 301 to www.example. com?

Thanks,

TJ

6:42 pm on Sept 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 9, 2005
posts:1509
votes: 0


Just answered that while you were posting.

here: [webmasterworld.com...]

Justin

8:58 pm on Sept 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member trillianjedi is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 15, 2003
posts:7256
votes: 3


Thanks for the link from the other thread JD.

I couldn't actually get this to work. The directory I don't want the redirect on is /phpmyadmin, so I tried this:-

RewriteEngine on
RewriteRule!^/phpmyadmin - [C]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

But it's still redirecting everything.

Any thoughts?

TJ

9:04 pm on Sept 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Is this code in httpd.conf, or in .htaccess?

Jim

9:21 pm on Sept 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member trillianjedi is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 15, 2003
posts:7256
votes: 3


Hey Jim.

In .htaccess.

It's the only code in there - this box does nothing else web-wise.

Thanks,

TJ

10:45 pm on Sept 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 9, 2005
posts:1509
votes: 0


The problem is the / (it is stripped before comparrison in the .htaccess.)

RewriteRule !^phpmyadmin - [C]

Justin

10:51 pm on Sept 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Or, a bit more efficient:

RewriteEngine on
RewriteCond $1 !^phpmyadmin
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Jim
11:07 am on Sept 8, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member trillianjedi is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 15, 2003
posts:7256
votes: 3


Thank you very much guys, works a treat now.

TJ

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members