Forum Moderators: phranque
parachute.mydomain.com
they are redirected to
mydomain.com/#*$!/index.php?au=parachute
is there anyway to tidy up the URL they are directed to so that
mydomain.com/#*$!/index.php?au=parachute
is rendered simply as parachute.mydomain.com?
does that make sense?
Any help is greatly appreciated
This is one of the two main functions of mod_rewrite, and which it does depends on the syntax you use.
If you externally redirect, then the server response tells the client re-request what it just asked for, using the new URL provided in the server redirect response.
If you internally rewrite, then you simply tell the server, "If this URL is requested, serve the contents from that file" -- The client is not involved. And you can just as easily substitute "If this URL is requested, generate the contents using the script in that file" for PHP-driven sites.
A redirect is a URL-to-URL translation, while a rewrite is a URL-to-non-default-filepath translation.
Jim
That makes no difference. The only change is to the syntax of your code; Change the rule so that it does an internal rewrite to the subdomain's file directory instead of doing an external redirect which exposes the subdirectory path to the visitor.
You may need to add a RewriteCond to prevent internal rewrite looping, but is all that is needed.
Jim
We have the mod-rewrite working 1/2 way. The rewrite is working to take the user to the right page, but when we attempt this via a subdomain it does not work.
We have the .htaccess file in both the root of the site and in the subdomain folder.
So www.example.com/page1/foo.html is working in the rewrite, but http://subdomain.example.com/page1/foo.html is not working.
.htaccess file info below.
================
Options +FollowSymLinks
RewriteEngine on
RewriteBase /whistler
RewriteRule ^http://whistler.example.com/(.*)/(.*).htm$ http://www.example.com/demo/lease_show.php?Lease=$2%{QUERY_STRING}
rewriteRule ^foo\.html$ http://www.example.com/index.php
===========================
Also, the other rewrite we're trying to do is to redirect a dynamic URl to a static URL. For some reason this is not working. The URl http://whistler.example.com/pemeberton/32.htm url should access the file www.example.com/demo/lease_show.php?Lease=32
Any thoughts why this is not working?
======================
Options +FollowSymLinks
RewriteEngine on
RewriteBase /demo
RewriteRule http://whistler.example.com/(.*)/(.*).htm$ http://www.example.com/demo/lease_show.php?Lease=$2%{QUERY_STRING}
==========================
[edited by: jdMorgan at 8:32 pm (utc) on July 3, 2007]
[edit reason] No URLs, please. See Terms of Service. [/edit]
For example, if the URL http://www.example.com/dir1/dir2/dir3/resize-logo.php?size=large is requested, then a RewriteRule residing at http://www.example.com/dir1/dir2/.htaccess would 'see' only a local URL-path of dir3/resize-logo.php -- again, all of the path info to the .htaccess file's directory is removed.
Also, it seems you've missed the distinction between an external redirect and an internal rewrite.
Based on what you've written, I'd suggest:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /whistler
RewriteCond %(HTTP_HOST) ^(www\.)?whistler\.example\.com
RewriteRule ^(([^/]+)/)+([^.]+)\.htm$ /demo/lease_show.php?Lease=$3 [QSA,L]
#
# Simple test rule
RewriteRule ^foo\.html$ http://www.example.com/index.php [R=301,L]
Options +FollowSymLinks
RewriteEngine on
RewriteBase /demo
RewriteCond %{HTTP_HOST} ^(www\.)?whistler\.example\.com
RewriteRule ^(([^/]+)/)+([^.]+)\.htm$ /demo/lease_show.php?Lease=$3 [QSA,L]
Jim