Please forgive this basic question. PHP noob here. I am trying to retrieve the domain from a URL (after my own domain). Similar to how DomainTools can be seen doing it here.
http://whois.domaintools.com/http://soccer.com
I then want to be able to store the "http://soccer.com" and also allow "http://whois.domaintools.com/http://soc ... r/file.php" or other things after that soccer.com domain, and store it as a variable....say $domain2search
I am trying to use .htaccess to pull this out, but keep getting 404 errors and such.
Thanks for any help,
Mike
Multiple domains in URL
Moderator: General Moderators
Re: Multiple domains in URL
You need a script to handle it, for starters. If it's called domain.php then
$_GET["domain"] is the site domain name, $_GET["request"] is the request URI (without the query, if there is one).
Code: Select all
RewriteRule ^/?http://([^/]+)(/.*)? domain.php?domain=$1&request=$2Re: Multiple domains in URL
Thanks for the speedy reply. This is what my htaccess file presently looks like
---------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteRule ^/?http://([^/]+)(/.*)? toolbar.php?domain=$1&request=$2
RewriteRule ^([aA0-zZ0]+)$ ?show=$1 [nc]
</IfModule>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
---------------------------------
toolbar.php is where I will be working with the URI. However page still breaks when I type in http://linkjelly.com/http://soccer.com for example.
---------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteRule ^/?http://([^/]+)(/.*)? toolbar.php?domain=$1&request=$2
RewriteRule ^([aA0-zZ0]+)$ ?show=$1 [nc]
</IfModule>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
---------------------------------
toolbar.php is where I will be working with the URI. However page still breaks when I type in http://linkjelly.com/http://soccer.com for example.
Re: Multiple domains in URL
Also toolbar can handle the variables we set up:
http://linkjelly.com/toolbar.php?domain ... request=22
http://linkjelly.com/toolbar.php?domain ... request=22
Re: Multiple domains in URL
What does the server log show Apache trying to serve?
Or you can add a [R] at the end of the RewriteRule to see for yourself, but change the destination to /toolbar.php... (only for this testing).
Or you can add a [R] at the end of the RewriteRule to see for yourself, but change the destination to /toolbar.php... (only for this testing).
Re: Multiple domains in URL
Apache Server log (Please excuse the unformatted version, couldnt find an export button in CPANEL):
[Tue Jan 26 17:40:26 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:26 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:27 2010] [notice] mod_fcgid: process /usr/local/cpanel/cgi-sys/default.fcgi(13710) exit(idle timeout), get stop signal 15 [Tue Jan 26 17:40:27 2010] [notice] mod_fcgid: process /usr/local/cpanel/cgi-sys/default.fcgi(14306) exit(idle timeout), get stop signal 15 PHP Warning: Zend Optimizer for PHP 5.2.x cannot be found (expected at '/usr/local/Zend/lib/Optimizer-2.5.10/php-5.2.x/ZendOptimizer.so') - try reinstalling the Zend Optimizer in Unknown on line 0 Can't use string ("2.3") as a HASH ref while "strict refs" in use at ./404.cgi line 162. [Tue Jan 26 17:40:28 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:29 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:30 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:30 2010] [error] [client 67.195.37.115] File does not exist: /usr/local/apache/htdocs/youtube Can't use string ("2.3") as a HASH ref while "strict refs" in use at /usr/local/apache/htdocs/404.cgi line 162. [Tue Jan 26 17:40:30 2010] [error] [client 67.195.37.115] Premature end of script headers: 404.cgi Can't use string ("2.3") as a HASH ref while "strict refs" in use at ./404.cgi line 162. [Tue Jan 26 17:40:31 2010] [error] [client 220.181.94.235] File does not exist: /usr/local/apache/htdocs/lavirgen.html [Tue Jan 26 17:40:31 2010] [error] [client 174.36.241.155] Failed loading /home/jasminen/ioncube/ioncube_loader_lin.so: /home/jasminen/ioncube/ioncube_loader_lin.so: undefined symbol: zend_throw_exception_hook [Tue Jan 26 17:40:33 2010] [error] [client 77.88.43.27] File does not exist: /usr/local/cpanel/3rdparty/mailman/archives/public/ode [Tue Jan 26 17:40:33 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. Can't call method "get" on an undefined value at calendar.pl line 338. Can't use string ("2.3") as a HASH ref while "strict refs" in use at ./404.cgi line 162. [Tue Jan 26 17:40:34 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. SUEXEC error_log:
[Tue Jan 26 17:40:26 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:26 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:27 2010] [notice] mod_fcgid: process /usr/local/cpanel/cgi-sys/default.fcgi(13710) exit(idle timeout), get stop signal 15 [Tue Jan 26 17:40:27 2010] [notice] mod_fcgid: process /usr/local/cpanel/cgi-sys/default.fcgi(14306) exit(idle timeout), get stop signal 15 PHP Warning: Zend Optimizer for PHP 5.2.x cannot be found (expected at '/usr/local/Zend/lib/Optimizer-2.5.10/php-5.2.x/ZendOptimizer.so') - try reinstalling the Zend Optimizer in Unknown on line 0 Can't use string ("2.3") as a HASH ref while "strict refs" in use at ./404.cgi line 162. [Tue Jan 26 17:40:28 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:29 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:30 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. [Tue Jan 26 17:40:30 2010] [error] [client 67.195.37.115] File does not exist: /usr/local/apache/htdocs/youtube Can't use string ("2.3") as a HASH ref while "strict refs" in use at /usr/local/apache/htdocs/404.cgi line 162. [Tue Jan 26 17:40:30 2010] [error] [client 67.195.37.115] Premature end of script headers: 404.cgi Can't use string ("2.3") as a HASH ref while "strict refs" in use at ./404.cgi line 162. [Tue Jan 26 17:40:31 2010] [error] [client 220.181.94.235] File does not exist: /usr/local/apache/htdocs/lavirgen.html [Tue Jan 26 17:40:31 2010] [error] [client 174.36.241.155] Failed loading /home/jasminen/ioncube/ioncube_loader_lin.so: /home/jasminen/ioncube/ioncube_loader_lin.so: undefined symbol: zend_throw_exception_hook [Tue Jan 26 17:40:33 2010] [error] [client 77.88.43.27] File does not exist: /usr/local/cpanel/3rdparty/mailman/archives/public/ode [Tue Jan 26 17:40:33 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. Can't call method "get" on an undefined value at calendar.pl line 338. Can't use string ("2.3") as a HASH ref while "strict refs" in use at ./404.cgi line 162. [Tue Jan 26 17:40:34 2010] [warn] RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored. SUEXEC error_log:
Re: Multiple domains in URL
My current .htaccess file
---------------
AddHandler application/x-httpd-php4 .php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.linkjelly.com$ [NC]
RewriteRule ^(.*)$ http://linkjelly.com/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ http://linkjelly.com/$1/ [R,L]
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteRule ^/?http://([^/]+)(/.*)? toolbar.php?domain=$1&request=$2
</IfModule>
------------------------------------
trying to hit this URL to no avail: http://linkjelly.com/http://soccer.com
really stumping me here.....
---------------
AddHandler application/x-httpd-php4 .php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.linkjelly.com$ [NC]
RewriteRule ^(.*)$ http://linkjelly.com/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ http://linkjelly.com/$1/ [R,L]
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteRule ^/?http://([^/]+)(/.*)? toolbar.php?domain=$1&request=$2
</IfModule>
------------------------------------
trying to hit this URL to no avail: http://linkjelly.com/http://soccer.com
really stumping me here.....