Add the following lines to the end of "httpd.conf" file (Virtual host section). <VirtualHost *:80> ServerAdmin you@example.com DocumentRoot C:/Docs/MySite ServerName www.example.com ServerAlias example.com *.example.com </VirtualHost> Code (markup): Also make sure that the default directory configuration defined to be as follow in the main server configuration. <Directory /> Options FollowSymLinks AllowOverride [B]All[/B] </Directory> Code (markup): If AllowOverride is set to None, probably mod rewrite may not work well. Hope it helps you.
Help 301 redirect. would like to redirect http://www.domain.com/index.php?topic=261.msg2157 to http://www.domain.com/index.php?topic=261
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^index.php?topic=(.*)\.msg(.*)$ http://www.domain.com/index.php?topic=$1 [R=301,L]
or Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^index.php?topic=(.*)\..*$ http://www\.domain\.com/index\.php?topic=$1 [R=301,L] Code (markup):
I am currently implementing this tutorial. I have got my htaccess working to load the static html with php version. I am now rewriting all my links so they point to .html instead of .php. However, search engines and people using bookmarks will continue to land on the .php URIs. I want to redirect them automatically to the correct html URIs. Is there really no way to do that in htaccess? I am finding that if I change my links to point to .html, they work OK when .html is already being used in the current URI, but if its the .php URI version the links dont work. Thus when a search engine or user from bookmark comes the links wont work.
If you don't have mod_rewrite or RewriteEngine is turned off you can use RedirectMatch 301. http://d.com/index.php?topic=261.msg2157 => http://d.com/index.php?topic=261 RedirectMatch 301 /index\.php\?topic=([0-9]+)\. http://d.com/index.php?topic=$1 Code (markup):
Heres the easiest way.. This code issues an SEO-friendly 301 redirect every time a file ending in .php is requested. The 301 redirect tells the requesting client that the new Location of the file is at permanent location site.com/file.html instead of site.com/file.php RedirectMatch 301 (.*)\.php http://www.site.com/$1.html Code (markup): Then you need to tell google that files ending in .php should be removed from the index. Follow googles advice and create a robots.txt file with the following content. This robots.txt code removes all files that end in .php from google and also removes and files with a ? QUERY_STRING in the url. User-agent: Googlebot Disallow: /*.php$ Disallow: /*?* Code (markup):
OK I added the robots file. I have trouble with the 301 redirect from php to html, ive tried for ages but cant get anything like that to work. I think when it works it makes an infinite loop as it passes pph -> html -> php -> html etc.. Anyway, the old php pages were not indexed well. only 7 pages were indexed and they had little to no pagerank. so i dont think SEO wise I get anything from passing them on to the new pages...? the main benefit would be to pass user with bookmarks over the correct page instead of a main index page, but like i say i cant get any redirect from php to html to work.
Could you give an example of a couple of your old urls with .php and also what you want them to be changed to? (you can leave your domain out)
You can avoid infinite loops by adding this code before the actual mod rewrite code. RewriteCond %{HTTP_HOST} ^www.example\.com [NC] RewriteCond %{THE_REQUEST} ^(.*)\.php\ [B]HTTP/[/B] RewriteRule ^(.*)\.php$ http://www.example.com/$1.html [R=301,L] Code (markup): Apache will issue 301 redirect only when the request part of the header sent by the browser contains HTTP (HTTP/1.1 or HTTP/1.0). Hence the redirect stuff will not get stuck with our actual static url implementation.
Nice vishwaa, here is another really handy infinite loop stopper that I use all the time. RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule .* - [L] Code (markup):
It took me about 5 hours of 500 and 404 errors but I finally managed to do it. I put all my html -> php redirects at the top, then the php -> html ones at the bottom with R=301 on them. I also used your: RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule .* - [L] Though it may not be necessary for me, I didnt test it. Thanks for your help.
Rewrite your urls with _ underscores to - hyphens. Based on article Rewrite underscores to hyphens for SEO URL This code sends a 301 redirect when it receives a request for an underscored url to the hyphenated url. d.com/the_first_apache_article.html ==> d.com/the-first-apache-article.html Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule !\.(html|php)$ - [S=4] RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes] RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes] RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes] RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes] RewriteCond %{ENV:uscor} ^Yes$ RewriteRule (.*) http://d.com/$1 [R=301,L] Code (markup):
Man, this is great stuff. Mind Boggling stuff. I will try it out. The potential time saved by this script is unbelievable. Many thanks.
i have the code But he is not functioning correctly, if to have access www.mysite.com.br/classificados/ does not work, if to have access www.mysite.com.br/classificados/classificados/ it works, but I want that he does not need to repeat /classificados somebody helps me?
hi guys, i am using this on-the-fly translation script here http://forums.digitalpoint.com/showthread.php?t=42057 i have a small problem with the my jump script being redirected to the translated pages of the destination domain. here is my problem here http://forums.digitalpoint.com/showpost.php?p=2523009&postcount=638 basically i need a mod rewrite that will redirect all example.com/language/de/jump-xxx.asp example.com/language/fr/jump-xxx.asp example.com/language/jp/jump-xxx.asp example.com/language/es/jump-xxx.asp example.com/language/ru/jump-xxx.asp etc... to example.com/jump-xxx.asp so that it would be redirected to the ORIGINAL language of the destination page. this is what i currently have RewriteRule ^jump-(.*).asp$ jump.php?id=$1 [L] this was done to avoid the problems with the "?id=" being converted to erroneous characters. Any help is very much appreciated.