Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite gives /httpdocs/httpdocs

         

Sen_Haerens

6:41 pm on Jan 14, 2005 (gmt 0)

10+ Year Member



The following rules are implemented in the httpd.conf:
<Directory "/usr/local/psa/home/vhosts/mydomain.com/httpdocs"> 
Options +FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ index.php?1=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?1=$1&2=$2 [L]
</Directory>

[mydomain.com...] and [mydomain.com...] errors 404 instead of [mydomain.com...]

Error.log tells me this:

Fri Jan 14 17:08:31 2005] [error] [client 217.136.105.135] File does not exist: 
/usr/local/psa/home/vhosts/mydomain.com/httpdocs/httpdocs, referer: [mydomain.com...]

How can I remove the extra /httpdocs? The hosting server is running Apache2 with Plesk 7.

[edited by: jdMorgan at 7:07 pm (utc) on Jan. 14, 2005]
[edit reason] Fixed side-scroll [/edit]

jdMorgan

7:13 pm on Jan 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sen_Haerens,

Welcome to WebmasterWorld!

It looks like you are missing the leading slash in the RewriteRule patterns:


<Directory "/usr/local/psa/home/vhosts/mydomain.com/httpdocs">
Options +FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule [b]^/[/b]([^/\.]+)/?$ /index.php?1=$1 [L]
RewriteRule [b]^/[/b]([^/\.]+)/([^/\.]+)/?$ /index.php?1=$1&2=$2 [L]
</Directory>

However, something may also be wrong with the Document_Root definition if mod_rewrite can "see" the "httpdocs" in the local URL-path.

Jim

Sen_Haerens

8:01 pm on Jan 14, 2005 (gmt 0)

10+ Year Member



Thanks for the friendly welcome :)

Well, since it it's a shared server I don't know if they can edit the Apache document_root

Here is the config for my domain:

AddType application/x-miva-compiled .mvc 
AddType application/x-miva-compiled .mv
Action application/x-miva-compiled /cgi-bin/mivamvc/mivavm
<Directory "/usr/local/psa/home/vhosts/mydomain.com/cgi-bin">
Options ExecCGI
</Directory>
<Directory "/usr/local/psa/home/vhosts/mydomain.com/httpdocs">
Options +FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ index.php?1=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?1=$1&2=$2 [L]
php_admin_value include_path "/usr/local/psa/home/vhosts/mydomain.com/httpdocs:."
php_admin_value open_basedir "/usr/local/psa/home/vhosts/mydomain.com/httpdocs:/tmp:/usr/local/bin:/usr/local/netpbm/bin"
AddDefaultCharset utf-8
</Directory>

If I put the rewrite rules in an .htaccess and test it on Apache at my home, the rules work perfectly even without the trailing slash at the beginning. Does this mean that it's surely a document_root problem? Can this be solved with RewriteBase?

jdMorgan

8:35 pm on Jan 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> If I put the rewrite rules in an .htaccess and test it on Apache at my home, the rules work perfectly even without the trailing slash at the beginning.

This is a difference between using mod_rewrite in httpd.conf and using it in .htaccess. Remember that in an .htaccess context, the URL "seen" by RewriteRule is adjusted to indicate the current local URL-path. So, in directory "/", the slash is removed, and in subdirectory "/subdir/", the "/subdir/" will be removed from the URL "seen" by RewriteRule.

Try using RewriteBase, and let us know if it helps.

Jim

Sen_Haerens

6:16 pm on Jan 17, 2005 (gmt 0)

10+ Year Member



Apache document root
/usr/local/psa/home/vhosts/mydomain.com/httpdocs.

I asked to add RewriteBase / to the httpd.conf. They restart Apache every 24h so I just have to wait another day to see if it works.