Need some help with .htaccess. My current code is: RewriteEngine On RewriteCond %{HTTP_HOST}!^(www\.¦$) [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ([^/\.]+)/$ show.php?a=$1 RewriteCond %{HTTP_HOST} ^wmtoolbox\.com RewriteRule ^(.*)$ http://www.wmtoolbox.com/$1 [R=301,L] RewriteBase / Code (markup): What is does: http://wmtoolbox.com >> http://www.wmtoolbox.com http://wmtoolbox.com/free/ >> http://www.wmtoolbox.com/show.php/?a=free Code (markup): What I need is: http://wmtoolbox.com/free/ >> http://www.wmtoolbox.com/free/ Code (markup): Basically, change the non-www into the www counterpart. With my code, it gets rid of the url mask and shows the ugly show.php/?a=keyword Any ideas?
on my site i do a site.com to www.site.com using below simple lines <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\.site\.com [NC] RewriteRule ^(.*) http://www.site.com/$1 [L,R=301] </IfModule> this then changes ALL / any URL from non-www to www.
Put this .htaccess file at root of your www directory: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^(.*) http://www.domain.com/$1 [L,R] Code (markup):
I have more simpler way . Using cPanel Just add " * " as a sub domain using cPanel . W8 for activation . After it gets activated . any sub domain will be using www.domain.com . and catch the domain name using php code . $domain="domain.com"; $host=$_SERVER[HTTP_HOST]; $sub_domain=explode($domain,$host); $sub_domain=$sub_domain[0]; echo $sub_domain; Code (markup): Check Out http://raxor.info . Made on same logic
So called ugly URLs are caused by this part of the RewriteRule ([^/\.]+)/$ show.php?a=$1 Code (markup):