Forum Moderators: phranque

Message Too Old, No Replies

url redirection and directory permission

         

Saturn

1:04 pm on Dec 3, 2007 (gmt 0)

10+ Year Member



I use this code in my .htaccess file

RewriteCond %{HTTP_HOST} ^dev.example.org$ [OR]
RewriteCond %{HTTP_HOST} ^www.dev.example.org$
RewriteRule ^/?(.*)$ http://www.example.org/$1 [R=301,L]

it work, perfectly. But I have my phpMyAdmin folder's permission going crazy when I put the code in my .htaccess.
It won't read CSS files and I cannot view databases etc...

What did I do wrong?

All I want to do is when someone goes to dev.example.org it will change it to www.example.org.

Also I tried working something to force URI http://www.example.org instead of http://example.org, but I failed as it conflicts with my mod_rewrite


RewriteCond %{HTTP_HOST} ^example.org
RewriteRule (.*) http://www.example.org/$1 [R=301,L]

How?
I type http://example.org/blah/
It forces uri to http://www.example.org/index.php?blah=bleh&... etc.

Do the order of conditions in .htaccess have something to do about it?

[edited by: encyclo at 1:28 pm (utc) on Dec. 3, 2007]
[edit reason] switched to example.org [/edit]

jdMorgan

2:00 pm on Dec 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's likely that your phpMyAdmin program doesn't like to be accessed from the www subdomain. If this is the case, then you can simply exclude it from being redirected.

The code below illustrates the following changes:

1) Combine non-canonical domain redirects.
2) Exclude phpMyAdmin folder from being redirected.
3) Other corrections and clean-ups.


RewriteCond %{REQUEST_URI} !^/[i]URL_path_to_phpMyAdmin_folder[/i]
RewriteCond %{HTTP_HOST} ^example\.org [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?dev\.example\.org [NC]
RewriteRule (.*) http://www.example.org/$1 [R=301,L]

Put your local URL-path to the phpMyAdmin folder into the pattern for the first RewriteCond; Include only the URL_path for that folder that follows the domain name.

Jim

Saturn

3:21 pm on Dec 3, 2007 (gmt 0)

10+ Year Member



Hi Jim,
I did try your code

RewriteCond %{REQUEST_URI} !^/home/exampleDotOrg/public_html/phpMyAdmin
RewriteCond %{HTTP_HOST} ^example\.org [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?dev\.example\.org [NC]
RewriteRule (.*) http://www.example.org/$1 [R=301,L]

But I still get a 401 error in phpMyAdmin.
<snip>

Note: .htaccess is inside public_html folder
Note: I also tried paths:
%{REQUEST_URI} !^/exampleDotOrg/public_html/phpMyAdmin
%{REQUEST_URI} !^/public_html/phpMyAdmin
%{REQUEST_URI} !^/phpMyAdmin

All failed :/

Also, I would like to add couple of redirections.
1. blah.example.org/(anything goes after) -> www.example.org/blah/(anything goes after)
2. blah1.example.org/(anything goes after) -> www.example.org/blah1/(anything goes after)

And so on, how can I do it properly?

[edited by: Saturn at 3:25 pm (utc) on Dec. 3, 2007]

[edited by: jdMorgan at 4:27 pm (utc) on Dec. 3, 2007]
[edit reason] No URLs please. [/edit]

jdMorgan

4:31 pm on Dec 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteCond %{REQUEST_URI} !^/phpMyAdmin 

should have worked. Did you flush your browser cache completely before testing?

As for the redirects, one thing you can do to help preserve your sanity is to refrain from adding 'features' until your core functions have been thoroughly tested and proven to work. This is a method that Microsoft might well profit from following... ;)

Jim

Saturn

5:12 pm on Dec 3, 2007 (gmt 0)

10+ Year Member



Mmm, I flushed everything and then restarted my browser. Not phpMyAdmin won't even read CSS files or access anything. Same 401 error :\

jdMorgan

5:21 pm on Dec 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at your server error log and make a list of all of the pages, images, css files, and scripts that phpAdmin is unsuccessfully trying to reference. Then add exclusions for those objects (or the common part of their paths) and see if that helps.

Jim

Saturn

5:49 pm on Dec 3, 2007 (gmt 0)

10+ Year Member



I thought I would allow everything inside phpMyAdmin's folder
RewriteCond %{REQUEST_URI}!^/phpMyAdmin/+(.*)$

But it didn't help (I couldn't find the error log :/)

It didn't help :¦

jdMorgan

6:09 pm on Dec 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is hardly any difference between your new pattern and the original. In fact, you new pattern is more restrictive, so stick with the original unanchored pattern.

Contact your host, and ask them where your error log is located. Trying to debug this problem without it may prove impossible.

Jim

[edited by: jdMorgan at 6:21 pm (utc) on Dec. 3, 2007]