Forum Moderators: phranque
If I use the flags [R=301,L] or [R=302,L], then the rule functions and transfers the request to the specified file or folder. However, it loses the parked domain name in the process. If I remove the R=301 or 302 flag I get a server 500 error when I try to access the URL controlled by the ruleset.
Here is an example of the one I am trying to get going right now, which is causing 500 errors unless I include the R=301 or R=302 flag. Assume that my actual domain is called example.net:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} example\.info [OR]
RewriteCond %{HTTP_HOST} example\.info
RewriteRule ^(.*)$ Folder/$1 [R=302,L]
### (This RewriteRule functions, but shows my actual domain and location in the addressbar (ht*p://www.example.net/Folder/file), not the parked domain - example.info/Folder/file.)
# RewriteRule ^(.*)$ Folder/$1 [L]
## (This commented-out RewriteRule causes a server 500 error but displays the correct parked domain name, example.info/Folder/file, in the addressbar!)
Is there anyway I can get the parked domain name to display in the addressbar without causing a server 500 error? Can somebody explain why using only the L flag causes a 500 error? I have read that using only the L is how one performs an invisible rewrite from one uri to another. Thanks, Wiz
2. Are you using the commented out rule with the conditions or as it appears without the conditions? If you are using it without the conditions, there is an infinite loop created, because there is nothing to stop Folder from being rewritten to Folder/file.html to Folder/Folder/file.html to Folder/Folder/Folder/file.html and on and on...
RewriteCond %{HTTP_REFERER} example\.info [OR]
RewriteCond %{HTTP_HOST} example\.info
RewriteRule ^(.*)$ /Folder/$1 [R=302,L]
RewriteCond %{REQUEST_URI} !^Folder
RewriteRule ^(.*)$ /Folder/$1 [L]
I have assumed the rules are in the .htaccess and added a preceding / to the right side. I also added a condition that should break the loop. The rewrite will only be performed on URI's that do not start with Folder.
3. Can this information be accessed from the main domain by users of that domain? If so, are you really trying to create multiple duplicate content domains?
Hope this helps.
Justin
RewriteCond %{HTTP_HOST} ^(www\.)?example\.info
RewriteCond %{REQUEST_URI} [b]!^/F[/b]older/
RewriteRule ^(.*)$ /Folder/$1 [L]
Start-anchor the domain if possible, as shown -- "(www\.)?" makes "www." optional.
I recommend that you do not bother with rewriting based on HTTP_REFERER -- it's likely to cause very 'weird' problems.
Jim
1. Are your rules in the .htaccess or in the httpd.conf file?
2. Are you using the commented out rule with the conditions or as it appears without the conditions?
3. Can this information be accessed from the main domain by users of that domain? If so, are you really trying to create multiple duplicate content domains?
If you are using it without the conditions, there is an infinite loop created, because there is nothing to stop Folder from being rewritten to Folder/file.html to Folder/Folder/file.html to Folder/Folder/Folder/file.html and on and on...
Here is what I ended up with, that works to give my parked domain an invisible rewrite in the browser, to a specified directory, with wildcards:
RewriteCond %{HTTP_REFERER} example\.info [OR]
RewriteCond %{HTTP_HOST} example\.info
RewriteCond %{REQUEST_URI}!^/Folder/
RewriteRule (.*) /Folder/$1 [L]
Thanks for the help and thanks to WebmasterWorld for providing this extraordinary Forum!