Forum Moderators: phranque
Server settings are:
<VirtualHost xyz.xy.xyz.xyz:80>
ServerAdmin webadm@example.com
DocumentRoot /var/www/htdocs/widgets.example.com
ServerName widgets.example.com
ErrorLog /var/log/httpd/widgets.example.com-error_log
CustomLog /var/log/httpd/widgets.example.com-access_log common
php_admin_flag safe_mode off
</VirtualHost>
<Directory "/var/www/htdocs/widgets.example.com">
Options +FollowSymLinks
AllowOverride All
RewriteEngine On
</Directory>
(and the same changing gismo for widgets for gismo.example.com)
I have tried using numerous rules in [widgets.example.com] .htacces
RewriteRule ^wsub/([0-9]+)-([0-9]+)-(.+)$ /gsub/index.php?category=$1&subcategory=$2 [NC,L]
OR
RewriteRule ^wsub/([0-9]+)-([0-9]+)-(.+)$ /var/www/htdocs/gizmo/gsub/index.php?category=$1&subcategory=$2 [NC,L]
but no result.
I guess full /var/www/htdocs/widgets.example.com creates problem, making impossible for rules in htaccess to jump from widgets.example.com to gizmo.example.com.
I haven't found any solution for this problem. Any ideas?
Have you tried something simple? If not, rename your current .htaccess file as a backup, and make a new one for testing with only this code in it:
Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www.webmasterworld.com/apache/ [R=301,L]
The path given for an internal rewrite should be relative to DocumentRoot. That is, the server will take care of prefixing DocumentRoot to the path you specify when mod_rewrite does the URL-to-filepath translation. You should not include the DocumentRoot path in your substitution URL-path.
Jim
My guess is when having
DocumentRoot /var/www/htdocs/widgets.example.com
and I try to internaly redirect to different subdomain using rule
RewriteRule ^wsub/([0-9]+)-([0-9]+)-(.+)$ /gsub/index.php?category=$1&subcategory=$2 [NC,L]
problem is that server is trying to locate:
/var/www/htdocs/widgets.example.com + /gsub/index.php?category=$1&subcategory=$2
instead
/var/www/htdocs/gadgets.example.com + /gsub/index.php?category=$1&subcategory=$2
How do I tell in .htaccess in just one specific RewrireRule "use different subdomain gadgets.example.com"
when settings for subdomain is:
<VirtualHost xyz.xy.xyz.xyz:80>
DocumentRoot /var/www/htdocs/widgets.example.com
ServerName widgets.example.com
</VirtualHost>
<Directory "/var/www/htdocs/widgets.example.com">
Options +FollowSymLinks
AllowOverride All
RewriteEngine On
</Directory>
Thanks.
So, you can rewrite to a subdirectory in the current domain's filespace if you like, or rewrite to a 'fake' subdirectory that is 'mapped' into a different domain-account's filespace using a *nix symlink, but you can't 'change subdomains' using internal server functions.
To the outside world, you have domains and resource locators. Inside the server you have files. The main job of a server is to allow the OS- and server- neutral URL system to be used on the Web, and to translate that location system into the filesystem paths used by the operating system on a specific server.
HTH,
Jim