Hi i just wondering if this possible to get current url without http:// and www. My site is http://www.wallpapersuper.com but i want to echo wallpapersuper.com If this is possible in html please let me know Thanks, Dellingter
Check with your hosting provider. This is related to your hosting. Or you can try 301 redirect through your page coding also.
In php, you'll have to use string parsing. Plenty of info on the net about that. In html, you'll have to use javascript string parsing. Plenty of info on the net about that too.
<?php echo str_replace('www.','', $_SERVER['SERVER_NAME']);?> // wallpapersuper.com PHP: Will echo out your domain name, whether it contains www. or not. You may also need to edit or create a .htaccess file and add a line of code, which tells your server to parse .html files as if it was a .php file.
The best thing for SEO is in any way to allow ONLY with OR without www, not both. Make a .htaccess file and place it in your public_html folder with the following content: RewriteEngine On RewriteCond %{HTTP_HOST} ^www.(.*?).([a-z]+)$ [NC] RewriteRule (.*) http://%1.%2/$1 [R=301,L] Code (markup):
I'm Asking about programming in php how we can get current url...You are telling me something about hosting first you need to read thread carefully.
If i got my answer over the internet then why should i am here ?i find Some php coding but thats not working thats why i am here coz i did not find a real answer of my question.
<?php $url="http://www.your-domain.com/"; //place your domain here // get host name from URL preg_match("/^(http:\/\/)?([^\/]+)/i",$url, $matches); $host = $matches[2]; // get last two segments of host name preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); echo "Output: {$matches[0]}\n"; ?> Code (markup): hope this will help you.
With regards to my post above, here's a sample of what you need to put in to a .htaccess file. If you dont have a .htaccess file on your server create one and upload it to your root/ directory ie: public_html, www, or htpdocs folder.... AddType application/x-httpd-php .html PHP:
var strurl = window.location.href; document.write(strurl.replace("http://www.", "")); you need to make once common URL for all Pages it will help you for SEO.
I use this code to get the full URL function selfURL(){ list($prot) = explode('/',strtolower($_SERVER['SERVER_PROTOCOL'])); $s = $_SERVER['HTTPS'] == 'on' ? 's' : ''; $port = $_SERVER['SERVER_PORT'] == '80' ? '' : ':'.$_SERVER['SERVER_PORT']; return $prot.$s.'://'.$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } echo selfURL(); Code (markup): I got that here http://asdlog.com/Get_URL_of_current_page Since this is not what you want you can change it like this function selfURL(){ $url = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; return str_replace('www.','',$url); } echo selfURL(); Code (markup): And it won't echo www. and anything in front of it.
You can also try this RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] or RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] PHP: