Hello. I've been messing with mod_rewrite for who knows how long now trying to do some SEO optimizations on my site and change my dynamic URLs into static ones. I've probably tried about 50 different combinations of things in my .htaccess file (both on the root of my domain and in the subdomain folder where my site lives) and nothing has worked yet. I know mod_rewrite is enabled as there's other rules in the root of my domain that work fine (not related to URL rewriting though). Can anyone help me and be extremely detailed about exactly how I need to go about this so I can make sure I cover all of my bases? For the categories on my site, the links now are like: http://downloads.littlbuger.info/index.php?cid=46 And I want them like: http://downloads.littlbuger.info/index/cid/46 The downloads/file description link now is like: http://downloads.littlbuger.info/index.php?dlid=576 And I want them like: http://downloads.littlbuger.info/index/dlid/576 And finally the actual download link to download each file is like: http://downloads.littlbuger.info/in...mid=576&sess=54822da15dab2e7155b1a2171150081b And I want them like: http://downloads.littlbuger.info/index/ACT/dl/id/575/symid/576/sess/54822da15dab2e7155b1a2171150081b I've been told in the past to do something like this: subdomain.domain.com/.htaccess Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^index/ACT/dl/id/([^.]+)/symid/([^.]+)/sess/([^.]+)$ index.php?ACT=dl&id=$1&symid=$2&sess=$3 [L] RewriteRule ^index/dlid/([^.]+)$ index.php?dlid=$1 [L] RewriteRule ^index/cid/([^.]+)$ index.php?cid=$1 [L] Code (markup): But that doesn't work. And I've tried using a query string version as I saw that helped someone else before, kind of like this (just for category links only): Options +Indexes +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{QUERY_STRING} ^cid=(.+)$ RewriteRule ^index\.php$ /index/%1 [L] Code (markup): And that didn't work either. What am I doing wrong? Please, I am desperate here and would love if someone could continue to help me until I get it working. I'd even be willing to pay if necessary. Thanks.
This should work: Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^index/ACT/dl/id/([0-9]+)/symid/([0-9]+)/sess/([0-9]+)$ index.php?ACT=dl&id=$1&symid=$2&sess=$3 [L] RewriteRule ^index/dlid/([0-9]+)$ index.php?dlid=$1 [L] RewriteRule ^index/cid/([0-9]+)$ index.php?cid=$1 [L] Code (markup):
Thanks for your reply, but the session ID can have letters and numbers, so wont the [0-9] not work here? Thanks.
Oops RewriteRule ^index/ACT/dl/id/([0-9]+)/symid/([0-9]+)/sess/([^/]{32})$ index.php?ACT=dl&id=$1&symid=$2&sess=$3 [L] Code (markup):
OK, just to clarify on some things before I can verify if it works or not: 1.) Do I need to restart Apache? 2.) Will my "new" links show up right away? 3.) Should I put this in my .htaccess file that's in my subdomain or my root domain (my site is in the subdomain)? 4.) Anything else required? Thanks.
1) No. 2) The rewrite will work right away. 3) Your subdomain. 4) Maybe you'll need to do some editing in your php code if that hasn't been done yet.
Well, I've added it and it still doesn't work. You can look here and see: http://downloads.littlbuger.info It's so strange as mod_rewrite is on and enabled and whatnot and the following is in my root domain .htaccess file which DOES work: # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName www.littlbuger.info AuthUserFile /home/littlbug/public_html/_vti_pvt/service.pwd AuthGroupFile /home/littlbug/public_html/_vti_pvt/service.grp RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://downloads.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://downloads.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://downloads.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://downloads.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://downloads2.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://downloads2.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://downloads2.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://downloads2.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://forums.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://forums.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://forums.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://forums.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://google.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://google.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://megan.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://megan.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://megan.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://megan.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://neowin.net/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://neowin.net$ [NC] RewriteCond %{HTTP_REFERER} !^http://paypal.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://paypal.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://status.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://status.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://status.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://status.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://stidyup.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://stidyup.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://stidyup.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://stidyup.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://support.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://support.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://support.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://support.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://testing.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://testing.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://testing.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://testing.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://ubcd4win.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://ubcd4win.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.downloads.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.downloads.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.forums.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.forums.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.google.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.google.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.google.com/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.google.com/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.littlbuger.info/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.littlbuger.info$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.littlbuger.info/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.littlbuger.info/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.neowin.net/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.neowin.net$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.neowin.net/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.neowin.net/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.paypal.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.paypal.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.paypal.com/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.paypal.com/*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.ubcd4win.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.ubcd4win.com$ [NC] RewriteCond %{HTTP_REFERER} !^https://www.paypal.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^https://www.paypal.com$ [NC] RewriteCond %{HTTP_REFERER} !^https://www.paypal.com/*/.*$ [NC] RewriteCond %{HTTP_REFERER} !^https://www.paypal.com/*$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.littlbuger.info [R,NC] Code (markup): Maybe something there or with cPanel is conflicting? What do you mean editing in my PHP code, as in like what? Thanks again for your help.
You can try this url for the Rails Live CD 0.3.1 on your site: http://downloads.littlbuger.info/index/dlid/634 The rewrite is working, but your php code doesn't print out the desired url. So it'll need to be edited.
Ahh yes, I see now. Well I guess I need to get a hold of the company that made my downloads script and see what I can do. Thank you so much for your help.
Any idea what certain thing needs to be editing in the general PHP code to make it print out the correct URLs? Even the script creator is confused with this, lol. Thanks.