paulgodard Posted July 4, 2007 Share Posted July 4, 2007 I am very new to Mod_Rewrite. However with the help of some people I managed to have my dynamic url converted to static one. But there is a hic (see the htaccess file below). Why does the second url not go to the correct page? How can I modify the rewriterule to do so without affecting the dynamic ->static conversion? Can the actual htaccess file have negative impact on SEO? http://www.paulgodard.com/Content_1010000000_artist.htm goes to the artist page OK http://paulgodard.com/Content_1010000000_artist.htm goes to the home page NOT OK htaccess file : ---------------- #Removes session id from URL - site will not work if cookies are not enabled php_flag session.use_trans_sid off #Redirects site from http://domain to http://www.domain (301 redirect) RewriteEngine on RewriteCond %{HTTP_HOST} ^paulgodard.com [NC] RewriteRule ^(.*)$ http://www.paulgodard.com/ [R=301,L] #Redirects static url (se friendly) to dynamic url (real filename) RewriteRule ^Content_(.+)_(.+).htm$ /Alpha/Page.php?Content_ID=$1&kw=$2 [nc] RewriteRule ^News_(.+)_(.+)_(.+).htm$ /Alpha/Page.php?Content_ID=$1&News_ID=$2&kw=$3 [nc] #Redirects error to page ErrorDocument 401 /AccessControl/AdminMessage.php?Error=401 ErrorDocument 404 /AccessControl/AdminMessage.php?Error=404 ErrorDocument 500 /AccessControl/AdminMessage.php?Error=500 Link to comment https://forums.phpfreaks.com/topic/58451-domain-and-wwwdomain-issues/ Share on other sites More sharing options...
paulgodard Posted July 5, 2007 Author Share Posted July 5, 2007 Is this a difficult question? Can someone help me please, I can not find any solution for the problem. Link to comment https://forums.phpfreaks.com/topic/58451-domain-and-wwwdomain-issues/#findComment-290597 Share on other sites More sharing options...
paulgodard Posted July 5, 2007 Author Share Posted July 5, 2007 This is amazing... I found the solution... There must be a $ after the first domain as well as /$1 to carry the querystring along in the rewrite rule, and the flag 'L' must be removed. This makes sense! #Redirects site from http://domain to http://www.domain (301 redirect) #Anything that follows the domain will be passed! RewriteEngine on RewriteCond %{HTTP_HOST} ^kidsofnature.com$ [NC] RewriteRule ^(.*)$ http://www.kidsofnature.com/$1 [R=301] #Redirects static url (se friendly) to dynamic url (real filename) RewriteRule ^Content_(.+)_(.+).htm$ /Alpha/Page.php?Content_ID=$1&kw=$2 [NC] RewriteRule ^News_(.+)_(.+)_(.+).htm$ /Alpha/Page.php?Content_ID=$1&News_ID=$2&kw=$3 [NC] BUT I have another question... My index.php file at the root level redirects to /Alpha/Page.php for many (good) reasons : // get optional query string $QueryString0 = $_SERVER['QUERY_STRING']; // load Page with query string $Link = "Alpha/Page.php"; if ($QueryString0) { $Link .= "?".$QueryString0; } header("location:".$Link); This means that I never see "www.kidsofnature.com" alone as the url but always with the "/Alpha/Page.php" appended. How can I avoid the url to change while I am redirecting the page? Via php or mod_rewrite? Link to comment https://forums.phpfreaks.com/topic/58451-domain-and-wwwdomain-issues/#findComment-290804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.