The reply was for you. I have just tried it, I have put it in my root htaccess file, and it is the same result. It redirect hhdirecto.net/breakdance to www.hhdirecto.net/breakdanc, but Don't redirect hhdirecto.net/letras to www.hhdirecto.net/letras because letras have another .htacces file RewriteEngine On RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1 RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1 Code (markup):
Try placing it in that htaccess file instead, but after the existing code you've shown above - let us know how it goes.
neither I have just tried this in my forder .htacces file RewriteEngine On RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1 RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1 RewriteCond %{HTTP_HOST} ^([^.]+\.net) [NC] RewriteRule (.*) http://www.%1/$1 [R=301,L] Code (markup):
Hi Tam, I used your code , it doesn't seem to redirect the files without www init. what could be the issue?
hmmm, looks as though you are running some sort of script? Since I don't know the script, or if you can configure it to point to www.yourdomain, maybe it would be easier to place that script in a subdomain and use the original htaccess for your main domain?
You need to place it in your main web folder (often 'public_html'), maybe you have placed it somewhere else? Does your host allow you to use htaccess? Just a quick explanation of what it does ... RewriteCond %{HTTP_HOST} ^([^.]+\.com) [NC] Code (markup): This line checks to make sure it's not a www or subdomain request, before running the next line ... RewriteRule (.*) http://www.%1/$1 [R=301,L] Code (markup): This line redirects the request to the corresponding page but with the www prefix.
As a matter of interest what was the result? The same as your previous post or in some way different?
Hi Tam, it works for folder and its not working for files. so still do you think we are having issue in running .htaccess or we are not in the root of the public_html
Can you give any examples? I am going to have to go for a while but will try and get back later, failing that, I'll be back in the morning. Sorry about that.
My hosting poeple also not sure why the code is not working. Can you guys tell me whether the following code is okay so that i can make sure that this is done with all our files. if($_SERVER["HTTP_HOST"] == "domain.com") { $URI = $_SERVER["REQUEST_URI"]; Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.domain.com$URI" ); exit(); }
Yes that works, but don't forget to change the domain.com element to your own domain. Its also a search engine friendly way of doing it, apparently. You just have to place it at the very beginning of every page, and every page has to be a .php page Glad you sorted it
yes, all are PHP files and i was lucky that i had a common file which was included in all our PHP files as first file, so i just put this code and everything went well. now both for folders and for files we are having the 301 redirect.
I should have added to my other post, that htere is a way to force your server to read html files as php files, but that also relies on an htaccess entry, so that may or may not be available to you (just as the problem with the htaccess mod_rewrite we tried before). If you want to try that at any time just add the following to the top of your htaccess file ... AddType application/x-httpd-php .html Code (markup):