homepage Welcome to WebmasterWorld Guest from 23.22.128.96
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess rewrite help
spunkle




msg:4260117
 9:53 am on Jan 30, 2011 (gmt 0)

Hey,

I have a problem with google crawling some links that i do not want it to crawl. These links should not exist and i do not know how google found them. I currently have a htaccess file to make url's more SE friendly but i'm not sure how to fix this new issue.

here is an example of the problem, google is crawling some links like:
http://www.example.com/?m=h&page=4/page1077/page5/page1116/page10/page1129/page7/page8

and the link should look like:
http://www.example.com/top_rated/page4

example 2:
http://www.example.com/?m=m&page=932/page928/page931/page1116/page1116/page1121/page2

should be:
http://www.example.com/most_viewed/page932



i don't know why all the "/page5/page1116/" etc are on the url.

i guess i do not have my htaccess setup correctly to achieve this?
below is my current htaccess file, can someone please help me with what i need to add or change to stop google from crawling these links, i guess i need to add or change a rewrite in the htaccess file?

current htaccess file:


RewriteEngine on

#Profile
RewriteRule ^profile/$ /profile
RewriteRule ^profile/([^/\.]+)$ index.php?profile=TRUE&m=$1
RewriteRule ^profile$ index.php?profile=TRUE

#Blog
RewriteRule ^blog/$ /blog [R=301]
RewriteRule ^blog/page([^/\.]+)$ index.php?m=b&page=$1
RewriteRule ^blog/([^/\.]+)$ index.php?m=b&bid=$1
RewriteRule ^blog$ index.php?m=b

#Blog Queue
RewriteRule ^blog_queue/$ /blog_queue [R=301]
RewriteRule ^blog_queue/page([^/\.]+)$ index.php?m=b_q&page=$1
RewriteRule ^blog_queue/([^/\.]+)$ index.php?m=b_q&bid=$1
RewriteRule ^blog_queue$ index.php?m=b_q

#Blog Drafts
RewriteRule ^blog_drafts/$ /blog_drafts [R=301]
RewriteRule ^blog_drafts/page([^/\.]+)$ index.php?m=b_d&page=$1
RewriteRule ^blog_drafts/([^/\.]+)$ index.php?m=b_d&bid=$1
RewriteRule ^blog_drafts$ index.php?m=b_d

#Stats
RewriteRule ^stats/$ /stats
RewriteRule ^stats$ index.php?stats=TRUE

#Pages
RewriteRule ^page([^/\.]+)/?$ index.php?page=$1

#Content Areas (user kept for beta testers)
RewriteRule ^user/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^user/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]
RewriteRule ^thumb/([^/\.]+)$ /inc/thumbs.php?id=$1

#Content Area (Relabeled to /channel - previous label kept for smooth upgrade path for beta users - 301 redirect)
RewriteRule ^channel/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^channel/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]

#Register
RewriteRule ^register/$ register
RewriteRule ^register$ index.php?register=TRUE
RewriteRule ^registration/([^/\.]+)$ index.php?registration=TRUE&un=$1
RewriteRule ^registration/([^/\.]+)/([^/\.]+)$ index.php?registration=TRUE&un=$1&verify=$2

#Password Reminder
RewriteRule ^lostpw/$ /lostpw
RewriteRule ^lostpw$ index.php?lostpw=TRUE

#Login
RewriteRule ^login/$ /login
RewriteRule ^login$ index.php?login=TRUE

#Logout
RewriteRule ^logout/$ /logout
RewriteRule ^logout$ index.php?logout=TRUE

#Search
RewriteRule ^search/$ /search
RewriteRule ^search/page([^/\.]+)$ index.php?search=1&page=$1
RewriteRule ^search$ index.php?search=1

#Directory
RewriteRule ^directory/$ /directory
RewriteRule ^directory/([^/\.]+)$ index.php?m=dir&s=$1
RewriteRule ^directory/([^/\.]+)/page([^/\.]+)$ index.php?m=dir&s=$1&page=$2

#Featured
RewriteRule ^featured/$ /featured
RewriteRule ^featured/page([^/\.]+)$ index.php?m=e&page=$1
RewriteRule ^featured$ index.php?m=e

#Top Rated
RewriteRule ^top_rated/$ /top_rated
RewriteRule ^top_rated/page([^/\.]+)$ index.php?m=h&page=$1
RewriteRule ^top_rated$ index.php?m=h

#Most Discussed
RewriteRule ^most_discussed/$ /most_discussed
RewriteRule ^most_discussed/page([^/\.]+)$ index.php?m=d&page=$1
RewriteRule ^most_discussed$ index.php?m=d

#Most Viewed
RewriteRule ^most_viewed/$ /most_viewed
RewriteRule ^most_viewed/page([^/\.]+)$ index.php?m=m&page=$1
RewriteRule ^most_viewed$ index.php?m=m

#Most Recent
RewriteRule ^most_recent/$ /new
RewriteRule ^most_recent/page([^/\.]+)$ index.php?m=n&page=$1
RewriteRule ^most_recent$ index.php?m=n

#Queued
RewriteRule ^queued/$ /queued
RewriteRule ^queued/page([^/\.]+)$ index.php?m=a_q&page=$1
RewriteRule ^queued$ index.php?m=a_q

#Import Queued
RewriteRule ^import-queued/$ /import-queued
RewriteRule ^import-queued/page([^/\.]+)$ index.php?m=i_q&page=$1
RewriteRule ^import-queued$ index.php?m=i_q

#Import Failed
RewriteRule ^import-failed/$ /import-failed
RewriteRule ^import-failed/page([^/\.]+)$ index.php?m=i_f&page=$1
RewriteRule ^import-failed$ index.php?m=i_f

#Title Editor
RewriteRule ^title-editor/$ /title-editor
RewriteRule ^title-editor$ index.php?m=ti

#SEO Tools
RewriteRule ^seo-tools/$ /seo-tools
RewriteRule ^seo-tools$ index.php?m=seo

#Channel Editor
RewriteRule ^channel-editor/$ /channel-editor
RewriteRule ^channel-editor$ index.php?m=ce

#Search Stats
RewriteRule ^search-stats/$ /search-stats
RewriteRule ^search-stats/page([^/\.]+)$ index.php?m=ss&page=$1
RewriteRule ^search-stats$ index.php?m=ss

#Disabled
RewriteRule ^disabled/$ /disabled
RewriteRule ^disabled/page([^/\.]+)$ index.php?m=a_d&page=$1
RewriteRule ^disabled$ index.php?m=a_d

#Favorites
RewriteRule ^favorites/$ /favorites
RewriteRule ^favorites/page([^/\.]+)$ index.php?m=f&page=$1
RewriteRule ^favorites$ index.php?m=f

#Subscriptions
RewriteRule ^subscriptions/$ /subscriptions
RewriteRule ^subscriptions/page([^/\.]+)$ index.php?m=s&page=$1
RewriteRule ^subscriptions$ index.php?m=s

#About
RewriteRule ^about/$ /about
RewriteRule ^about$ about.php

#Contact
RewriteRule ^contact/$ /about
RewriteRule ^contact$ index.php

#Webmasters
RewriteRule ^webmasters/$ /about
RewriteRule ^webmasters$ index.php

#Popular Tags
RewriteRule ^popular_tags/$ /popular_tags
RewriteRule ^popular_tags/([^/\.]+)$ index.php?m=p&m=$1
RewriteRule ^popular_tags$ index.php?m=p

#Tags
RewriteRule ^tag/$ /tags
RewriteRule ^tag/([^/\.]+)$ index.php?tag=$1
RewriteRule ^tag/([^/\.]+)/page([^/\.]+)$ index.php?tag=$1&page=$2

#Categories
RewriteRule ^category/$ /category
RewriteRule ^category/([^/\.]+)$ index.php?cat=1&scat=$1
RewriteRule ^category/([^/\.]+)/page([^/\.]+)$ index.php?cat=1&scat=$1&page=$2
RewriteRule ^category$ index.php?cat=1

#Group List
RewriteRule ^girls/([^/\.]+)$ index.php?m=girls&s=$1

#Content Area
RewriteRule ^([^/\.]+)$ index.php?uid=$1
RewriteRule ^([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&page=$2
RewriteRule ^([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3
RewriteRule ^([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&page=$3
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&page=$4
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&iid=$4

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]

[edited by: jdMorgan at 8:39 pm (utc) on Feb 7, 2011]
[edit reason] example.com to suppress auto-linking [/edit]

 

g1smd




msg:4260203
 5:40 pm on Jan 30, 2011 (gmt 0)


The redirects MUST be listed before any of the rewrites: index redirect first, the non-www redirect next.

EVERY RewriteRule should have the [L] flag added.

spunkle




msg:4260206
 5:49 pm on Jan 30, 2011 (gmt 0)

any chance of a quick example of what you mean G1smd? sorry i'm new to this.

spunkle




msg:4260317
 11:28 pm on Jan 30, 2011 (gmt 0)

ok i have made the changes that g1smd suggested. Those suggestions don't address my initial problem though.

can anyone shed some light on my problem?

thanks very much :)

spunkle




msg:4260841
 10:37 pm on Jan 31, 2011 (gmt 0)

bump for help, also if no one can help, can anyone suggest a htaccess forum that i can try and get some info from?

thanks

g1smd




msg:4260885
 12:13 am on Feb 1, 2011 (gmt 0)

Let's see the new code and we can proceed.

spunkle




msg:4261040
 9:18 am on Feb 1, 2011 (gmt 0)

Hey g1smd,

here is the new htaccess, thanks for the help:

mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

#Prevent timeouts during upload (May require editing of php.ini)
php_value upload_max_filesize 800M
php_value post_max_size 800M
php_value max_execution_time 1600
php_value max_input_time 1600
php_value register_globals 0
ErrorDocument 404 /404.php


RewriteEngine on



RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ [domain.com...] [R=301,L]

RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ [domain.com...] [L,R=301]


#Profile
RewriteRule ^profile/$ /profile [L]
RewriteRule ^profile/([^/\.]+)$ index.php?profile=TRUE&m=$1 [L]
RewriteRule ^profile$ index.php?profile=TRUE [L]

#Blog
RewriteRule ^blog/$ /blog [R=301,L]
RewriteRule ^blog/page([^/\.]+)$ index.php?m=b&page=$1 [L]
RewriteRule ^blog/([^/\.]+)$ index.php?m=b&bid=$1 [L]
RewriteRule ^blog$ index.php?m=b [L]

#Blog Queue
RewriteRule ^blog_queue/$ /blog_queue [R=301,L]
RewriteRule ^blog_queue/page([^/\.]+)$ index.php?m=b_q&page=$1 [L]
RewriteRule ^blog_queue/([^/\.]+)$ index.php?m=b_q&bid=$1 [L]
RewriteRule ^blog_queue$ index.php?m=b_q [L]

#Blog Drafts
RewriteRule ^blog_drafts/$ /blog_drafts [R=301,L]
RewriteRule ^blog_drafts/page([^/\.]+)$ index.php?m=b_d&page=$1 [L]
RewriteRule ^blog_drafts/([^/\.]+)$ index.php?m=b_d&bid=$1 [L]
RewriteRule ^blog_drafts$ index.php?m=b_d [L]

#Stats
RewriteRule ^stats/$ /stats [L]
RewriteRule ^stats$ index.php?stats=TRUE [L]

#Pages
RewriteRule ^page([^/\.]+)/?$ index.php?page=$1 [L]

#Content Areas (user kept for beta testers)
RewriteRule ^user/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^user/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]
RewriteRule ^thumb/([^/\.]+)$ /inc/thumbs.php?id=$1 [L]

#Content Area (Relabeled to /channel - previous label kept for smooth upgrade path for beta users - 301 redirect)
RewriteRule ^channel/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^channel/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]

#Register
RewriteRule ^register/$ register [L]
RewriteRule ^register$ index.php?register=TRUE [L]
RewriteRule ^registration/([^/\.]+)$ index.php?registration=TRUE&un=$1 [L]
RewriteRule ^registration/([^/\.]+)/([^/\.]+)$ index.php?registration=TRUE&un=$1&verify=$2 [L]

#Password Reminder
RewriteRule ^lostpw/$ /lostpw [L]
RewriteRule ^lostpw$ index.php?lostpw=TRUE [L]

#Login
RewriteRule ^login/$ /login [L]
RewriteRule ^login$ index.php?login=TRUE [L]

#Logout
RewriteRule ^logout/$ /logout [L]
RewriteRule ^logout$ index.php?logout=TRUE [L]

#Search
RewriteRule ^search/$ /search [L]
RewriteRule ^search/page([^/\.]+)$ index.php?search=1&page=$1 [L]
RewriteRule ^search$ index.php?search=1 [L]

#Directory
RewriteRule ^directory/$ /directory [L]
RewriteRule ^directory/([^/\.]+)$ index.php?m=dir&s=$1 [L]
RewriteRule ^directory/([^/\.]+)/page([^/\.]+)$ index.php?m=dir&s=$1&page=$2 [L]

#Featured
RewriteRule ^featured/$ /featured [L]
RewriteRule ^featured/page([^/\.]+)$ index.php?m=e&page=$1 [L]
RewriteRule ^featured$ index.php?m=e [L]

#Top Rated
RewriteRule ^top_rated/$ /top_rated [L]
RewriteRule ^top_rated/page([^/\.]+)$ index.php?m=h&page=$1 [L]
RewriteRule ^top_rated$ index.php?m=h [L]

#Most Discussed
RewriteRule ^most_discussed/$ /most_discussed [L]
RewriteRule ^most_discussed/page([^/\.]+)$ index.php?m=d&page=$1 [L]
RewriteRule ^most_discussed$ index.php?m=d [L]

#Most Viewed
RewriteRule ^most_viewed/$ /most_viewed [L]
RewriteRule ^most_viewed/page([^/\.]+)$ index.php?m=m&page=$1 [L]
RewriteRule ^most_viewed$ index.php?m=m [L]

#Most Recent
RewriteRule ^most_recent/$ /new [L]
RewriteRule ^most_recent/page([^/\.]+)$ index.php?m=n&page=$1 [L]
RewriteRule ^most_recent$ index.php?m=n [L]

#Queued
RewriteRule ^queued/$ /queued [L]
RewriteRule ^queued/page([^/\.]+)$ index.php?m=a_q&page=$1 [L]
RewriteRule ^queued$ index.php?m=a_q [L]

#Import Queued
RewriteRule ^import-queued/$ /import-queued [L]
RewriteRule ^import-queued/page([^/\.]+)$ index.php?m=i_q&page=$1 [L]
RewriteRule ^import-queued$ index.php?m=i_q [L]

#Import Failed
RewriteRule ^import-failed/$ /import-failed [L]
RewriteRule ^import-failed/page([^/\.]+)$ index.php?m=i_f&page=$1 [L]
RewriteRule ^import-failed$ index.php?m=i_f [L]

#Title Editor
RewriteRule ^title-editor/$ /title-editor [L]
RewriteRule ^title-editor$ index.php?m=ti [L]

#SEO Tools
RewriteRule ^seo-tools/$ /seo-tools [L]
RewriteRule ^seo-tools$ index.php?m=seo [L]

#Channel Editor
RewriteRule ^channel-editor/$ /channel-editor [L]
RewriteRule ^channel-editor$ index.php?m=ce [L]

#Search Stats
RewriteRule ^search-stats/$ /search-stats [L]
RewriteRule ^search-stats/page([^/\.]+)$ index.php?m=ss&page=$1 [L]
RewriteRule ^search-stats$ index.php?m=ss [L]

#Disabled
RewriteRule ^disabled/$ /disabled [L]
RewriteRule ^disabled/page([^/\.]+)$ index.php?m=a_d&page=$1 [L]
RewriteRule ^disabled$ index.php?m=a_d [L]

#Favorites
RewriteRule ^favorites/$ /favorites [L]
RewriteRule ^favorites/page([^/\.]+)$ index.php?m=f&page=$1 [L]
RewriteRule ^favorites$ index.php?m=f [L]

#Subscriptions
RewriteRule ^subscriptions/$ /subscriptions [L]
RewriteRule ^subscriptions/page([^/\.]+)$ index.php?m=s&page=$1 [L]
RewriteRule ^subscriptions$ index.php?m=s [L]

#About
RewriteRule ^about/$ /about [L]
RewriteRule ^about$ about.php [L]

#Contact
RewriteRule ^contact/$ /about [L]
RewriteRule ^contact$ index.php [L]

#Webmasters
RewriteRule ^webmasters/$ /about [L]
RewriteRule ^webmasters$ index.php [L]

#Popular Tags
RewriteRule ^popular_tags/$ /popular_tags [L]
RewriteRule ^popular_tags/([^/\.]+)$ index.php?m=p&m=$1 [L]
RewriteRule ^popular_tags$ index.php?m=p [L]

#Tags
RewriteRule ^tag/$ /tags [L]
RewriteRule ^tag/([^/\.]+)$ index.php?tag=$1 [L]
RewriteRule ^tag/([^/\.]+)/page([^/\.]+)$ index.php?tag=$1&page=$2 [L]

#Categories
RewriteRule ^category/$ /category [L]
RewriteRule ^category/([^/\.]+)$ index.php?cat=1&scat=$1 [L]
RewriteRule ^category/([^/\.]+)/page([^/\.]+)$ index.php?cat=1&scat=$1&page=$2 [L]
RewriteRule ^category$ index.php?cat=1 [L]

#Group List
RewriteRule ^girls/([^/\.]+)$ index.php?m=girls&s=$1 [L]

#Content Area
RewriteRule ^([^/\.]+)$ index.php?uid=$1 [L]
RewriteRule ^([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&page=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&page=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&page=$4 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&iid=$4 [L]

g1smd




msg:4261067
 10:08 am on Feb 1, 2011 (gmt 0)

Use example.com to stop the forum auto-linking the URLs.

RewriteRule ^blog_drafts/$ /blog_drafts [R=301,L]

As a 301 redirect it should include the domain name:

RewriteRule ^blog_drafts/$ http://www.example.com/blog_drafts [R=301,L]

This also applies to several other rules above.


Next, examine the first line of each block of code (i.e. the line directly after the comment).
RewriteRule ^stats/$ /stats [L]

This rule is an internal rewrite. Surely it should also be an external redirect. Add the [R=301,L] flag and add the domain name to the target, as above.

RewriteRule ^stats/$ http://www.example.com/stats [R=301,L]

This applies to the first line of most of the code blocks above.


Finally, once you have corrected the syntax of all of those redirects, all of those redirects should be moved so they appear at the very beginning of the RewriteRule code. That is, the "page" redirects should appear before the index and non-www redirects.

The rewrites stay where they are and the redirects move to the beginning of the code.

spunkle




msg:4261803
 6:24 pm on Feb 2, 2011 (gmt 0)

Hi g1smd,

I have read your instructions and have applied them to the best of my knowledge, I didn't understand this bit so don't think i have done it correctly:
"Finally, once you have corrected the syntax of all of those redirects, all of those redirects should be moved so they appear at the very beginning of the RewriteRule code. That is, the "page" redirects should appear before the index and non-www redirects.

The rewrites stay where they are and the redirects move to the beginning of the code. "



Here is my new htaccess with all of the amendments i have done. Can you let me know if i have done any of it wrong?

I tested my site and these url's are still accessible so not sure what i need to do to stop that?:
example.com/?m=h&page=4/page1077/page5/page1116/page10/page1129/page7/page7

thanks for your help with this, much appreciated!

New htaccess:

mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

#Prevent timeouts during upload (May require editing of php.ini)
php_value upload_max_filesize 800M
php_value post_max_size 800M
php_value max_execution_time 1600
php_value max_input_time 1600
php_value register_globals 0
ErrorDocument 404 /404.php


RewriteEngine on



RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ example.com/$1 [L,R=301]


#Profile
RewriteRule ^profile/$ example.com/profile [R=301,L]
RewriteRule ^profile/([^/\.]+)$ index.php?profile=TRUE&m=$1 [L]
RewriteRule ^profile$ index.php?profile=TRUE [L]

#Blog
RewriteRule ^blog/$ example.com/blog [R=301,L]
RewriteRule ^blog/page([^/\.]+)$ index.php?m=b&page=$1 [L]
RewriteRule ^blog/([^/\.]+)$ index.php?m=b&bid=$1 [L]
RewriteRule ^blog$ index.php?m=b [L]

#Blog Queue
RewriteRule ^blog_queue/$ example.com/blog_queue [R=301,L]
RewriteRule ^blog_queue/page([^/\.]+)$ index.php?m=b_q&page=$1 [L]
RewriteRule ^blog_queue/([^/\.]+)$ index.php?m=b_q&bid=$1 [L]
RewriteRule ^blog_queue$ index.php?m=b_q [L]

#Blog Drafts
RewriteRule ^blog_drafts/$ example.com/blog_drafts [R=301,L]
RewriteRule ^blog_drafts/page([^/\.]+)$ index.php?m=b_d&page=$1 [L]
RewriteRule ^blog_drafts/([^/\.]+)$ index.php?m=b_d&bid=$1 [L]
RewriteRule ^blog_drafts$ index.php?m=b_d [L]

#Stats
RewriteRule ^stats/$ example.com/stats [R=301,L]
RewriteRule ^stats$ index.php?stats=TRUE [L]

#Pages
RewriteRule ^page([^/\.]+)/?$ index.php?page=$1 [L]

#Content Areas (user kept for beta testers)
RewriteRule ^user/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^user/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]
RewriteRule ^thumb/([^/\.]+)$ /inc/thumbs.php?id=$1 [L]

#Content Area (Relabeled to /channel - previous label kept for smooth upgrade path for beta users - 301 redirect)
RewriteRule ^channel/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^channel/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]

#Register
RewriteRule ^register/$ example.com/register [R=301,L]
RewriteRule ^register$ index.php?register=TRUE [L]
RewriteRule ^registration/([^/\.]+)$ index.php?registration=TRUE&un=$1 [L]
RewriteRule ^registration/([^/\.]+)/([^/\.]+)$ index.php?registration=TRUE&un=$1&verify=$2 [L]

#Password Reminder
RewriteRule ^lostpw/$ example.com/lostpw [R=301,L]
RewriteRule ^lostpw$ index.php?lostpw=TRUE [L]

#Login
RewriteRule ^login/$ example.com/login [R=301,L]
RewriteRule ^login$ index.php?login=TRUE [L]

#Logout
RewriteRule ^logout/$ example.com/logout [R=301,L]
RewriteRule ^logout$ index.php?logout=TRUE [L]

#Search
RewriteRule ^search/$ example.com/search [R=301,L]
RewriteRule ^search/page([^/\.]+)$ index.php?search=1&page=$1 [L]
RewriteRule ^search$ index.php?search=1 [L]

#Directory
RewriteRule ^directory/$ example.com/directory [R=301,L]
RewriteRule ^directory/([^/\.]+)$ index.php?m=dir&s=$1 [L]
RewriteRule ^directory/([^/\.]+)/page([^/\.]+)$ index.php?m=dir&s=$1&page=$2 [L]

#Featured
RewriteRule ^featured/$ example.com/featured [R=301,L]
RewriteRule ^featured/page([^/\.]+)$ index.php?m=e&page=$1 [L]
RewriteRule ^featured$ index.php?m=e [L]

#Top Rated
RewriteRule ^top_rated/$ example.com/top_rated [R=301,L]
RewriteRule ^top_rated/page([^/\.]+)$ index.php?m=h&page=$1 [L]
RewriteRule ^top_rated$ index.php?m=h [L]

#Most Discussed
RewriteRule ^most_discussed/$ example.com/most_discussed [R=301,L]
RewriteRule ^most_discussed/page([^/\.]+)$ index.php?m=d&page=$1 [L]
RewriteRule ^most_discussed$ index.php?m=d [L]

#Most Viewed
RewriteRule ^most_viewed/$ example.com/most_viewed [R=301,L]
RewriteRule ^most_viewed/page([^/\.]+)$ index.php?m=m&page=$1 [L]
RewriteRule ^most_viewed$ index.php?m=m [L]

#Most Recent
RewriteRule ^most_recent/$ example.com/new [R=301,L]
RewriteRule ^most_recent/page([^/\.]+)$ index.php?m=n&page=$1 [L]
RewriteRule ^most_recent$ index.php?m=n [L]

#Queued
RewriteRule ^queued/$ example.com/queued [R=301,L]
RewriteRule ^queued/page([^/\.]+)$ index.php?m=a_q&page=$1 [L]
RewriteRule ^queued$ index.php?m=a_q [L]

#Import Queued
RewriteRule ^import-queued/$ example.com/import-queued [R=301,L]
RewriteRule ^import-queued/page([^/\.]+)$ index.php?m=i_q&page=$1 [L]
RewriteRule ^import-queued$ index.php?m=i_q [L]

#Import Failed
RewriteRule ^import-failed/$ example.com/import-failed [R=301,L]
RewriteRule ^import-failed/page([^/\.]+)$ index.php?m=i_f&page=$1 [L]
RewriteRule ^import-failed$ index.php?m=i_f [L]

#Title Editor
RewriteRule ^title-editor/$ example.com/title-editor [R=301,L]
RewriteRule ^title-editor$ index.php?m=ti [L]

#SEO Tools
RewriteRule ^seo-tools/$ example.com/seo-tools [R=301,L]
RewriteRule ^seo-tools$ index.php?m=seo [L]

#Channel Editor
RewriteRule ^channel-editor/$ example.com/channel-editor [R=301,L]
RewriteRule ^channel-editor$ index.php?m=ce [L]

#Search Stats
RewriteRule ^search-stats/$ example.com/search-stats [L]
RewriteRule ^search-stats/page([^/\.]+)$ index.php?m=ss&page=$1 [L]
RewriteRule ^search-stats$ index.php?m=ss [L]

#Disabled
RewriteRule ^disabled/$ example.com/disabled [R=301,L]
RewriteRule ^disabled/page([^/\.]+)$ index.php?m=a_d&page=$1 [L]
RewriteRule ^disabled$ index.php?m=a_d [L]

#Favorites
RewriteRule ^favorites/$ example.com/favorites [R=301,L]
RewriteRule ^favorites/page([^/\.]+)$ index.php?m=f&page=$1 [L]
RewriteRule ^favorites$ index.php?m=f [L]

#Subscriptions
RewriteRule ^subscriptions/$ example.com/subscriptions [R=301,L]
RewriteRule ^subscriptions/page([^/\.]+)$ index.php?m=s&page=$1 [L]
RewriteRule ^subscriptions$ index.php?m=s [L]

#About
RewriteRule ^about/$ example.com/about [R=301,L]
RewriteRule ^about$ about.php [L]

#Contact
RewriteRule ^contact/$ example.com/about [R=301,L]
RewriteRule ^contact$ index.php [L]

#Webmasters
RewriteRule ^webmasters/$ example.com/about [R=301,L]
RewriteRule ^webmasters$ index.php [L]

#Popular Tags
RewriteRule ^popular_tags/$ example.com/popular_tags [R=301,L]
RewriteRule ^popular_tags/([^/\.]+)$ index.php?m=p&m=$1 [L]
RewriteRule ^popular_tags$ index.php?m=p [L]

#Tags
RewriteRule ^tag/$ example.com/tags [R=301,L]
RewriteRule ^tag/([^/\.]+)$ index.php?tag=$1 [L]
RewriteRule ^tag/([^/\.]+)/page([^/\.]+)$ index.php?tag=$1&page=$2 [L]

#Categories
RewriteRule ^category/$ example.com/category [R=301,L]
RewriteRule ^category/([^/\.]+)$ index.php?cat=1&scat=$1 [L]
RewriteRule ^category/([^/\.]+)/page([^/\.]+)$ index.php?cat=1&scat=$1&page=$2 [L]
RewriteRule ^category$ index.php?cat=1 [L]

#Group List
RewriteRule ^girls/([^/\.]+)$ index.php?m=girls&s=$1 [L]

#Content Area
RewriteRule ^([^/\.]+)$ index.php?uid=$1 [L]
RewriteRule ^([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&page=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&page=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&page=$4 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&iid=$4 [L]

g1smd




msg:4261809
 6:36 pm on Feb 2, 2011 (gmt 0)

All of the lines with both [R=301,L] on the end, and the domain name within, need to have http:// added in front of the domain name.

If there are any lines with [R=301,L] on the end, and the http:// AND the domain name are BOTH MISSING, then both of those things must be added.

Finally, all of those lines that end with [R=301,L] and ONLY those lines, need to be moved - one at a time - to be at the very start of the code.

The end result will be that ALL of the lines with [R=301,L] will be listed all together at the top of the code, and ALL of the lines with just [L] will be all together at the bottom of the code.

spunkle




msg:4261957
 11:38 pm on Feb 2, 2011 (gmt 0)

ok, I have made the changes suggested. I think that i have made all of them correctly, can you please confirm this is now correct?

here is the newest htaccess:


mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

#Prevent timeouts during upload (May require editing of php.ini)
php_value upload_max_filesize 800M
php_value post_max_size 800M
php_value max_execution_time 1600
php_value max_input_time 1600
php_value register_globals 0
ErrorDocument 404 /404.php


RewriteEngine on



RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]


#Moved Codes
RewriteRule ^category/$ http://www.example.com/category [R=301,L]
RewriteRule ^tag/$ http://www.example.com/tags [R=301,L]
RewriteRule ^popular_tags/$ http://www.example.com/popular_tags [R=301,L]
RewriteRule ^webmasters/$ http://www.example.com/about [R=301,L]
RewriteRule ^contact/$ http://www.example.com/about [R=301,L]
RewriteRule ^about/$ http://www.example.com/about [R=301,L]
RewriteRule ^subscriptions/$ http://www.example.com/subscriptions [R=301,L]
RewriteRule ^favorites/$ http://www.example.com/favorites [R=301,L]
RewriteRule ^disabled/$ http://www.example.com/disabled [R=301,L]
RewriteRule ^search-stats/$ http://www.example.com/search-stats [R=301,L]
RewriteRule ^channel-editor/$ http://www.example.com/channel-editor [R=301,L]
RewriteRule ^seo-tools/$ http://www.example.com/seo-tools [R=301,L]
RewriteRule ^title-editor/$ http://www.example.com/title-editor [R=301,L]
RewriteRule ^import-failed/$ http://www.example.com/import-failed [R=301,L]
RewriteRule ^import-queued/$ http://www.example.com/import-queued [R=301,L]
RewriteRule ^queued/$ http://www.example.com/queued [R=301,L]
RewriteRule ^most_recent/$ http://www.example.com/new [R=301,L]
RewriteRule ^most_viewed/$ http://www.example.com/most_viewed [R=301,L]
RewriteRule ^most_discussed/$ http://www.example.com/most_discussed [R=301,L]
RewriteRule ^top_rated/$ http://www.example.com/top_rated [R=301,L]
RewriteRule ^featured/$ http://www.example.com/featured [R=301,L]
RewriteRule ^directory/$ http://www.example.com/directory [R=301,L]
RewriteRule ^search/$ http://www.example.com/search [R=301,L]
RewriteRule ^logout/$ http://www.example.com/logout [R=301,L]
RewriteRule ^login/$ http://www.example.com/login [R=301,L]
RewriteRule ^lostpw/$ http://www.example.com/lostpw [R=301,L]
RewriteRule ^register/$ http://www.example.com/register [R=301,L]
#Content Area (Relabeled to /channel - previous label kept for smooth upgrade path for beta users - 301 redirect)
RewriteRule ^channel/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^channel/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]

RewriteRule ^user/([^/\.]+)$ /$1 [R=301,L]
RewriteRule ^user/([^/\.]+)/page([^/\.]+)$ /$1/page$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)$ /$1/$2 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/page$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^user/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]
RewriteRule ^stats/$ http://www.example.com/stats [R=301,L]
RewriteRule ^blog_drafts/$ http://www.example.com/blog_drafts [R=301,L]
RewriteRule ^blog_queue/$ http://www.example.com/blog_queue [R=301,L]
RewriteRule ^blog/$ http://www.example.com/blog [R=301,L]
RewriteRule ^profile/$ http://www.example.com/profile [R=301,L]




#Profile

RewriteRule ^profile/([^/\.]+)$ index.php?profile=TRUE&m=$1 [L]
RewriteRule ^profile$ index.php?profile=TRUE [L]

#Blog

RewriteRule ^blog/page([^/\.]+)$ index.php?m=b&page=$1 [L]
RewriteRule ^blog/([^/\.]+)$ index.php?m=b&bid=$1 [L]
RewriteRule ^blog$ index.php?m=b [L]

#Blog Queue

RewriteRule ^blog_queue/page([^/\.]+)$ index.php?m=b_q&page=$1 [L]
RewriteRule ^blog_queue/([^/\.]+)$ index.php?m=b_q&bid=$1 [L]
RewriteRule ^blog_queue$ index.php?m=b_q [L]

#Blog Drafts

RewriteRule ^blog_drafts/page([^/\.]+)$ index.php?m=b_d&page=$1 [L]
RewriteRule ^blog_drafts/([^/\.]+)$ index.php?m=b_d&bid=$1 [L]
RewriteRule ^blog_drafts$ index.php?m=b_d [L]

#Stats

RewriteRule ^stats$ index.php?stats=TRUE [L]

#Pages
RewriteRule ^page([^/\.]+)/?$ index.php?page=$1 [L]

#Content Areas (user kept for beta testers)
RewriteRule ^thumb/([^/\.]+)$ /inc/thumbs.php?id=$1 [L]


#Register

RewriteRule ^register$ index.php?register=TRUE [L]
RewriteRule ^registration/([^/\.]+)$ index.php?registration=TRUE&un=$1 [L]
RewriteRule ^registration/([^/\.]+)/([^/\.]+)$ index.php?registration=TRUE&un=$1&verify=$2 [L]

#Password Reminder

RewriteRule ^lostpw$ index.php?lostpw=TRUE [L]

#Login

RewriteRule ^login$ index.php?login=TRUE [L]

#Logout

RewriteRule ^logout$ index.php?logout=TRUE [L]

#Search

RewriteRule ^search/page([^/\.]+)$ index.php?search=1&page=$1 [L]
RewriteRule ^search$ index.php?search=1 [L]

#Directory

RewriteRule ^directory/([^/\.]+)$ index.php?m=dir&s=$1 [L]
RewriteRule ^directory/([^/\.]+)/page([^/\.]+)$ index.php?m=dir&s=$1&page=$2 [L]

#Featured

RewriteRule ^featured/page([^/\.]+)$ index.php?m=e&page=$1 [L]
RewriteRule ^featured$ index.php?m=e [L]

#Top Rated

RewriteRule ^top_rated/page([^/\.]+)$ index.php?m=h&page=$1 [L]
RewriteRule ^top_rated$ index.php?m=h [L]

#Most Discussed

RewriteRule ^most_discussed/page([^/\.]+)$ index.php?m=d&page=$1 [L]
RewriteRule ^most_discussed$ index.php?m=d [L]

#Most Viewed

RewriteRule ^most_viewed/page([^/\.]+)$ index.php?m=m&page=$1 [L]
RewriteRule ^most_viewed$ index.php?m=m [L]

#Most Recent

RewriteRule ^most_recent/page([^/\.]+)$ index.php?m=n&page=$1 [L]
RewriteRule ^most_recent$ index.php?m=n [L]

#Queued

RewriteRule ^queued/page([^/\.]+)$ index.php?m=a_q&page=$1 [L]
RewriteRule ^queued$ index.php?m=a_q [L]

#Import Queued

RewriteRule ^import-queued/page([^/\.]+)$ index.php?m=i_q&page=$1 [L]
RewriteRule ^import-queued$ index.php?m=i_q [L]

#Import Failed

RewriteRule ^import-failed/page([^/\.]+)$ index.php?m=i_f&page=$1 [L]
RewriteRule ^import-failed$ index.php?m=i_f [L]

#Title Editor

RewriteRule ^title-editor$ index.php?m=ti [L]

#SEO Tools

RewriteRule ^seo-tools$ index.php?m=seo [L]

#Channel Editor

RewriteRule ^channel-editor$ index.php?m=ce [L]

#Search Stats

RewriteRule ^search-stats/page([^/\.]+)$ index.php?m=ss&page=$1 [L]
RewriteRule ^search-stats$ index.php?m=ss [L]

#Disabled

RewriteRule ^disabled/page([^/\.]+)$ index.php?m=a_d&page=$1 [L]
RewriteRule ^disabled$ index.php?m=a_d [L]

#Favorites

RewriteRule ^favorites/page([^/\.]+)$ index.php?m=f&page=$1 [L]
RewriteRule ^favorites$ index.php?m=f [L]

#Subscriptions

RewriteRule ^subscriptions/page([^/\.]+)$ index.php?m=s&page=$1 [L]
RewriteRule ^subscriptions$ index.php?m=s [L]

#About

RewriteRule ^about$ about.php [L]

#Contact

RewriteRule ^contact$ index.php [L]

#Webmasters

RewriteRule ^webmasters$ index.php [L]

#Popular Tags

RewriteRule ^popular_tags/([^/\.]+)$ index.php?m=p&m=$1 [L]
RewriteRule ^popular_tags$ index.php?m=p [L]

#Tags

RewriteRule ^tag/([^/\.]+)$ index.php?tag=$1 [L]
RewriteRule ^tag/([^/\.]+)/page([^/\.]+)$ index.php?tag=$1&page=$2 [L]

#Categories

RewriteRule ^category/([^/\.]+)$ index.php?cat=1&scat=$1 [L]
RewriteRule ^category/([^/\.]+)/page([^/\.]+)$ index.php?cat=1&scat=$1&page=$2 [L]
RewriteRule ^category$ index.php?cat=1 [L]

#Group List
RewriteRule ^girls/([^/\.]+)$ index.php?m=girls&s=$1 [L]

#Content Area
RewriteRule ^([^/\.]+)$ index.php?uid=$1 [L]
RewriteRule ^([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&page=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&page=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&page=$4 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ index.php?uid=$1&pid=$2&gid=$3&iid=$4 [L]

g1smd




msg:4261962
 11:49 pm on Feb 2, 2011 (gmt 0)

There are a number of rules with [R=301,L] flags that do not have the protocol and domain name added yet.

Additionally, the index and the non-www redirects must be the last of the redirects, positioned just before the first rewrite.

Redirects affect the URLs users see. You need to get them out of the way before any of the rewrites get down to the business of serving the content.

spunkle




msg:4261968
 12:09 am on Feb 3, 2011 (gmt 0)

i guess you mean that these [R=301,L] don't have the url/protocal added but i have no idea where i would put the url, can you advise me?

RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ /$1/$2/$3/page$4 [R=301,L]
RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /$1/$2/$3/$4 [R=301,L]

g1smd




msg:4261983
 12:59 am on Feb 3, 2011 (gmt 0)

In the same place it appears in all of the other redirects: after the space after the $ sign, immediately before, and joined to, the / of the new URL path.

spunkle




msg:4262003
 1:21 am on Feb 3, 2011 (gmt 0)

so like this?:


RewriteRule ^channel/([^/\.]+)/([^/\.]+)/([^/\.]+)/page([^/\.]+)$ http://www.example.com/$1/$2/$3/page$4 [R=301,L]

g1smd




msg:4262135
 8:06 am on Feb 3, 2011 (gmt 0)

Yes, except that
([^/\.]+) should be ([^/.]+) too.
spunkle




msg:4262171
 10:14 am on Feb 3, 2011 (gmt 0)

Hey g1smd,

i made those changes, this is now what i have as htaccess, is this correct?:


mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

#Prevent timeouts during upload (May require editing of php.ini)
php_value upload_max_filesize 800M
php_value post_max_size 800M
php_value max_execution_time 1600
php_value max_input_time 1600
php_value register_globals 0
ErrorDocument 404 /404.php


RewriteEngine on



#Moved Codes
RewriteRule ^category/$ http://www.example.com/category [R=301,L]
RewriteRule ^tag/$ http://www.example.com/tags [R=301,L]
RewriteRule ^popular_tags/$ http://www.example.com/popular_tags [R=301,L]
RewriteRule ^webmasters/$ http://www.example.com/about [R=301,L]
RewriteRule ^contact/$ http://www.example.com/about [R=301,L]
RewriteRule ^about/$ http://www.example.com/about [R=301,L]
RewriteRule ^subscriptions/$ http://www.example.com/subscriptions [R=301,L]
RewriteRule ^favorites/$ http://www.example.com/favorites [R=301,L]
RewriteRule ^disabled/$ http://www.example.com/disabled [R=301,L]
RewriteRule ^search-stats/$ http://www.example.com/search-stats [R=301,L]
RewriteRule ^channel-editor/$ http://www.example.com/channel-editor [R=301,L]
RewriteRule ^seo-tools/$ http://www.example.com/seo-tools [R=301,L]
RewriteRule ^title-editor/$ http://www.example.com/title-editor [R=301,L]
RewriteRule ^import-failed/$ http://www.example.com/import-failed [R=301,L]
RewriteRule ^import-queued/$ http://www.example.com/import-queued [R=301,L]
RewriteRule ^queued/$ http://www.example.com/queued [R=301,L]
RewriteRule ^most_recent/$ http://www.example.com/new [R=301,L]
RewriteRule ^most_viewed/$ http://www.example.com/most_viewed [R=301,L]
RewriteRule ^most_discussed/$ http://www.example.com/most_discussed [R=301,L]
RewriteRule ^top_rated/$ http://www.example.com/top_rated [R=301,L]
RewriteRule ^featured/$ http://www.example.com/featured [R=301,L]
RewriteRule ^directory/$ http://www.example.com/directory [R=301,L]
RewriteRule ^search/$ http://www.example.com/search [R=301,L]
RewriteRule ^logout/$ http://www.example.com/logout [R=301,L]
RewriteRule ^login/$ http://www.example.com/login [R=301,L]
RewriteRule ^lostpw/$ http://www.example.com/lostpw [R=301,L]
RewriteRule ^register/$ http://www.example.com/register [R=301,L]
#Content Area (Relabeled to /channel - previous label kept for smooth upgrade path for beta users - 301 redirect)
RewriteRule ^channel/([^/.]+)$ http://www.example.com//$1 [R=301,L]
RewriteRule ^channel/([^/.]+)/page([^/.]+)$ http://www.example.com//$1/page$2 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)$ http://www.example.com//$1/$2 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com//$1/$2/page$3 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com//$1/$2/$3 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com//$1/$2/$3/page$4 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com//$1/$2/$3/$4 [R=301,L]

RewriteRule ^user/([^/.]+)$ http://www.example.com//$1 [R=301,L]
RewriteRule ^user/([^/.]+)/page([^/.]+)$ http://www.example.com//$1/page$2 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)$ http://www.example.com//$1/$2 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com//$1/$2/page$3 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com//$1/$2/$3 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com//$1/$2/$3/page$4 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com//$1/$2/$3/$4 [R=301,L]
RewriteRule ^stats/$ http://www.example.com/stats [R=301,L]
RewriteRule ^blog_drafts/$ http://www.example.com/blog_drafts [R=301,L]
RewriteRule ^blog_queue/$ http://www.example.com/blog_queue [R=301,L]
RewriteRule ^blog/$ http://www.example.com/blog [R=301,L]
RewriteRule ^profile/$ http://www.example.com/profile [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]




#Profile

RewriteRule ^profile/([^/.]+)$ index.php?profile=TRUE&m=$1 [L]
RewriteRule ^profile$ index.php?profile=TRUE [L]

#Blog

RewriteRule ^blog/page([^/.]+)$ index.php?m=b&page=$1 [L]
RewriteRule ^blog/([^/.]+)$ index.php?m=b&bid=$1 [L]
RewriteRule ^blog$ index.php?m=b [L]

#Blog Queue

RewriteRule ^blog_queue/page([^/.]+)$ index.php?m=b_q&page=$1 [L]
RewriteRule ^blog_queue/([^/.]+)$ index.php?m=b_q&bid=$1 [L]
RewriteRule ^blog_queue$ index.php?m=b_q [L]

#Blog Drafts

RewriteRule ^blog_drafts/page([^/.]+)$ index.php?m=b_d&page=$1 [L]
RewriteRule ^blog_drafts/([^/.]+)$ index.php?m=b_d&bid=$1 [L]
RewriteRule ^blog_drafts$ index.php?m=b_d [L]

#Stats

RewriteRule ^stats$ index.php?stats=TRUE [L]

#Pages
RewriteRule ^page([^/.]+)/?$ index.php?page=$1 [L]

#Content Areas (user kept for beta testers)
RewriteRule ^thumb/([^/.]+)$ /inc/thumbs.php?id=$1 [L]


#Register

RewriteRule ^register$ index.php?register=TRUE [L]
RewriteRule ^registration/([^/.]+)$ index.php?registration=TRUE&un=$1 [L]
RewriteRule ^registration/([^/.]+)/([^/.]+)$ index.php?registration=TRUE&un=$1&verify=$2 [L]

#Password Reminder

RewriteRule ^lostpw$ index.php?lostpw=TRUE [L]

#Login

RewriteRule ^login$ index.php?login=TRUE [L]

#Logout

RewriteRule ^logout$ index.php?logout=TRUE [L]

#Search

RewriteRule ^search/page([^/.]+)$ index.php?search=1&page=$1 [L]
RewriteRule ^search$ index.php?search=1 [L]

#Directory

RewriteRule ^directory/([^/.]+)$ index.php?m=dir&s=$1 [L]
RewriteRule ^directory/([^/.]+)/page([^/.]+)$ index.php?m=dir&s=$1&page=$2 [L]

#Featured

RewriteRule ^featured/page([^/.]+)$ index.php?m=e&page=$1 [L]
RewriteRule ^featured$ index.php?m=e [L]

#Top Rated

RewriteRule ^top_rated/page([^/.]+)$ index.php?m=h&page=$1 [L]
RewriteRule ^top_rated$ index.php?m=h [L]

#Most Discussed

RewriteRule ^most_discussed/page([^/.]+)$ index.php?m=d&page=$1 [L]
RewriteRule ^most_discussed$ index.php?m=d [L]

#Most Viewed

RewriteRule ^most_viewed/page([^/.]+)$ index.php?m=m&page=$1 [L]
RewriteRule ^most_viewed$ index.php?m=m [L]

#Most Recent

RewriteRule ^most_recent/page([^/.]+)$ index.php?m=n&page=$1 [L]
RewriteRule ^most_recent$ index.php?m=n [L]

#Queued

RewriteRule ^queued/page([^/.]+)$ index.php?m=a_q&page=$1 [L]
RewriteRule ^queued$ index.php?m=a_q [L]

#Import Queued

RewriteRule ^import-queued/page([^/.]+)$ index.php?m=i_q&page=$1 [L]
RewriteRule ^import-queued$ index.php?m=i_q [L]

#Import Failed

RewriteRule ^import-failed/page([^/.]+)$ index.php?m=i_f&page=$1 [L]
RewriteRule ^import-failed$ index.php?m=i_f [L]

#Title Editor

RewriteRule ^title-editor$ index.php?m=ti [L]

#SEO Tools

RewriteRule ^seo-tools$ index.php?m=seo [L]

#Channel Editor

RewriteRule ^channel-editor$ index.php?m=ce [L]

#Search Stats

RewriteRule ^search-stats/page([^/.]+)$ index.php?m=ss&page=$1 [L]
RewriteRule ^search-stats$ index.php?m=ss [L]

#Disabled

RewriteRule ^disabled/page([^/.]+)$ index.php?m=a_d&page=$1 [L]
RewriteRule ^disabled$ index.php?m=a_d [L]

#Favorites

RewriteRule ^favorites/page([^/.]+)$ index.php?m=f&page=$1 [L]
RewriteRule ^favorites$ index.php?m=f [L]

#Subscriptions

RewriteRule ^subscriptions/page([^/.]+)$ index.php?m=s&page=$1 [L]
RewriteRule ^subscriptions$ index.php?m=s [L]

#About

RewriteRule ^about$ about.php [L]

#Contact

RewriteRule ^contact$ index.php [L]

#Webmasters

RewriteRule ^webmasters$ index.php [L]

#Popular Tags

RewriteRule ^popular_tags/([^/.]+)$ index.php?m=p&m=$1 [L]
RewriteRule ^popular_tags$ index.php?m=p [L]

#Tags

RewriteRule ^tag/([^/.]+)$ index.php?tag=$1 [L]
RewriteRule ^tag/([^/.]+)/page([^/.]+)$ index.php?tag=$1&page=$2 [L]

#Categories

RewriteRule ^category/([^/.]+)$ index.php?cat=1&scat=$1 [L]
RewriteRule ^category/([^/.]+)/page([^/.]+)$ index.php?cat=1&scat=$1&page=$2 [L]
RewriteRule ^category$ index.php?cat=1 [L]

#Group List
RewriteRule ^girls/([^/.]+)$ index.php?m=girls&s=$1 [L]

#Content Area
RewriteRule ^([^/.]+)$ index.php?uid=$1 [L]
RewriteRule ^([^/.]+)/page([^/.]+)$ index.php?uid=$1&page=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)/page([^/.]+)$ index.php?uid=$1&pid=$2&page=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/page([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3&page=$4 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3&iid=$4 [L]

g1smd




msg:4262495
 11:33 pm on Feb 3, 2011 (gmt 0)

There are a number of double slashes within the path part of many URLs.

Those are obvious typos. Fix those and then test using "Live HTTP Headers" or similar.

spunkle




msg:4262680
 9:25 am on Feb 4, 2011 (gmt 0)

Hey,

I have fixed those typos, my mistake. I have tested the new htaccess and the trouble url's are still accessable. really appreciate your help with this.

this is a problem url:
example.com/?m=h&page=4/page1077/page5/page1116/page10/page1129/page7/page7

should be:
example.com/top_rated/page4

here is the newest htaccess:


mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

#Prevent timeouts during upload (May require editing of php.ini)
php_value upload_max_filesize 800M
php_value post_max_size 800M
php_value max_execution_time 1600
php_value max_input_time 1600
php_value register_globals 0
ErrorDocument 404 /404.php


RewriteEngine on



#Moved Codes
RewriteRule ^category/$ http://www.example.com/category [R=301,L]
RewriteRule ^tag/$ http://www.example.com/tags [R=301,L]
RewriteRule ^popular_tags/$ http://www.example.com/popular_tags [R=301,L]
RewriteRule ^webmasters/$ http://www.example.com/about [R=301,L]
RewriteRule ^contact/$ http://www.example.com/about [R=301,L]
RewriteRule ^about/$ http://www.example.com/about [R=301,L]
RewriteRule ^subscriptions/$ http://www.example.com/subscriptions [R=301,L]
RewriteRule ^favorites/$ http://www.example.com/favorites [R=301,L]
RewriteRule ^disabled/$ http://www.example.com/disabled [R=301,L]
RewriteRule ^search-stats/$ http://www.example.com/search-stats [R=301,L]
RewriteRule ^channel-editor/$ http://www.example.com/channel-editor [R=301,L]
RewriteRule ^seo-tools/$ http://www.example.com/seo-tools [R=301,L]
RewriteRule ^title-editor/$ http://www.example.com/title-editor [R=301,L]
RewriteRule ^import-failed/$ http://www.example.com/import-failed [R=301,L]
RewriteRule ^import-queued/$ http://www.example.com/import-queued [R=301,L]
RewriteRule ^queued/$ http://www.example.com/queued [R=301,L]
RewriteRule ^most_recent/$ http://www.example.com/new [R=301,L]
RewriteRule ^most_viewed/$ http://www.example.com/most_viewed [R=301,L]
RewriteRule ^most_discussed/$ http://www.example.com/most_discussed [R=301,L]
RewriteRule ^top_rated/$ http://www.example.com/top_rated [R=301,L]
RewriteRule ^featured/$ http://www.example.com/featured [R=301,L]
RewriteRule ^directory/$ http://www.example.com/directory [R=301,L]
RewriteRule ^search/$ http://www.example.com/search [R=301,L]
RewriteRule ^logout/$ http://www.example.com/logout [R=301,L]
RewriteRule ^login/$ http://www.example.com/login [R=301,L]
RewriteRule ^lostpw/$ http://www.example.com/lostpw [R=301,L]
RewriteRule ^register/$ http://www.example.com/register [R=301,L]
#Content Area (Relabeled to /channel - previous label kept for smooth upgrade path for beta users - 301 redirect)
RewriteRule ^channel/([^/.]+)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^channel/([^/.]+)/page([^/.]+)$ http://www.example.com/$1/page$2 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)$ http://www.example.com/$1/$2 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com/$1/$2/page$3 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com/$1/$2/$3 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com/$1/$2/$3/page$4 [R=301,L]
RewriteRule ^channel/([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com/$1/$2/$3/$4 [R=301,L]

RewriteRule ^user/([^/.]+)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^user/([^/.]+)/page([^/.]+)$ http://www.example.com/$1/page$2 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)$ http://www.example.com/$1/$2 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com/$1/$2/page$3 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com/$1/$2/$3 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/([^/.]+)/page([^/.]+)$ http://www.example.com/$1/$2/$3/page$4 [R=301,L]
RewriteRule ^user/([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)$ http://www.example.com/$1/$2/$3/$4 [R=301,L]
RewriteRule ^stats/$ http://www.example.com/stats [R=301,L]
RewriteRule ^blog_drafts/$ http://www.example.com/blog_drafts [R=301,L]
RewriteRule ^blog_queue/$ http://www.example.com/blog_queue [R=301,L]
RewriteRule ^blog/$ http://www.example.com/blog [R=301,L]
RewriteRule ^profile/$ http://www.example.com/profile [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]




#Profile

RewriteRule ^profile/([^/.]+)$ index.php?profile=TRUE&m=$1 [L]
RewriteRule ^profile$ index.php?profile=TRUE [L]

#Blog

RewriteRule ^blog/page([^/.]+)$ index.php?m=b&page=$1 [L]
RewriteRule ^blog/([^/.]+)$ index.php?m=b&bid=$1 [L]
RewriteRule ^blog$ index.php?m=b [L]

#Blog Queue

RewriteRule ^blog_queue/page([^/.]+)$ index.php?m=b_q&page=$1 [L]
RewriteRule ^blog_queue/([^/.]+)$ index.php?m=b_q&bid=$1 [L]
RewriteRule ^blog_queue$ index.php?m=b_q [L]

#Blog Drafts

RewriteRule ^blog_drafts/page([^/.]+)$ index.php?m=b_d&page=$1 [L]
RewriteRule ^blog_drafts/([^/.]+)$ index.php?m=b_d&bid=$1 [L]
RewriteRule ^blog_drafts$ index.php?m=b_d [L]

#Stats

RewriteRule ^stats$ index.php?stats=TRUE [L]

#Pages
RewriteRule ^page([^/.]+)/?$ index.php?page=$1 [L]

#Content Areas (user kept for beta testers)
RewriteRule ^thumb/([^/.]+)$ /inc/thumbs.php?id=$1 [L]


#Register

RewriteRule ^register$ index.php?register=TRUE [L]
RewriteRule ^registration/([^/.]+)$ index.php?registration=TRUE&un=$1 [L]
RewriteRule ^registration/([^/.]+)/([^/.]+)$ index.php?registration=TRUE&un=$1&verify=$2 [L]

#Password Reminder

RewriteRule ^lostpw$ index.php?lostpw=TRUE [L]

#Login

RewriteRule ^login$ index.php?login=TRUE [L]

#Logout

RewriteRule ^logout$ index.php?logout=TRUE [L]

#Search

RewriteRule ^search/page([^/.]+)$ index.php?search=1&page=$1 [L]
RewriteRule ^search$ index.php?search=1 [L]

#Directory

RewriteRule ^directory/([^/.]+)$ index.php?m=dir&s=$1 [L]
RewriteRule ^directory/([^/.]+)/page([^/.]+)$ index.php?m=dir&s=$1&page=$2 [L]

#Featured

RewriteRule ^featured/page([^/.]+)$ index.php?m=e&page=$1 [L]
RewriteRule ^featured$ index.php?m=e [L]

#Top Rated

RewriteRule ^top_rated/page([^/.]+)$ index.php?m=h&page=$1 [L]
RewriteRule ^top_rated$ index.php?m=h [L]

#Most Discussed

RewriteRule ^most_discussed/page([^/.]+)$ index.php?m=d&page=$1 [L]
RewriteRule ^most_discussed$ index.php?m=d [L]

#Most Viewed

RewriteRule ^most_viewed/page([^/.]+)$ index.php?m=m&page=$1 [L]
RewriteRule ^most_viewed$ index.php?m=m [L]

#Most Recent

RewriteRule ^most_recent/page([^/.]+)$ index.php?m=n&page=$1 [L]
RewriteRule ^most_recent$ index.php?m=n [L]

#Queued

RewriteRule ^queued/page([^/.]+)$ index.php?m=a_q&page=$1 [L]
RewriteRule ^queued$ index.php?m=a_q [L]

#Import Queued

RewriteRule ^import-queued/page([^/.]+)$ index.php?m=i_q&page=$1 [L]
RewriteRule ^import-queued$ index.php?m=i_q [L]

#Import Failed

RewriteRule ^import-failed/page([^/.]+)$ index.php?m=i_f&page=$1 [L]
RewriteRule ^import-failed$ index.php?m=i_f [L]

#Title Editor

RewriteRule ^title-editor$ index.php?m=ti [L]

#SEO Tools

RewriteRule ^seo-tools$ index.php?m=seo [L]

#Channel Editor

RewriteRule ^channel-editor$ index.php?m=ce [L]

#Search Stats

RewriteRule ^search-stats/page([^/.]+)$ index.php?m=ss&page=$1 [L]
RewriteRule ^search-stats$ index.php?m=ss [L]

#Disabled

RewriteRule ^disabled/page([^/.]+)$ index.php?m=a_d&page=$1 [L]
RewriteRule ^disabled$ index.php?m=a_d [L]

#Favorites

RewriteRule ^favorites/page([^/.]+)$ index.php?m=f&page=$1 [L]
RewriteRule ^favorites$ index.php?m=f [L]

#Subscriptions

RewriteRule ^subscriptions/page([^/.]+)$ index.php?m=s&page=$1 [L]
RewriteRule ^subscriptions$ index.php?m=s [L]

#About

RewriteRule ^about$ about.php [L]

#Contact

RewriteRule ^contact$ index.php [L]

#Webmasters

RewriteRule ^webmasters$ index.php [L]

#Popular Tags

RewriteRule ^popular_tags/([^/.]+)$ index.php?m=p&m=$1 [L]
RewriteRule ^popular_tags$ index.php?m=p [L]

#Tags

RewriteRule ^tag/([^/.]+)$ index.php?tag=$1 [L]
RewriteRule ^tag/([^/.]+)/page([^/.]+)$ index.php?tag=$1&page=$2 [L]

#Categories

RewriteRule ^category/([^/.]+)$ index.php?cat=1&scat=$1 [L]
RewriteRule ^category/([^/.]+)/page([^/.]+)$ index.php?cat=1&scat=$1&page=$2 [L]
RewriteRule ^category$ index.php?cat=1 [L]

#Group List
RewriteRule ^girls/([^/.]+)$ index.php?m=girls&s=$1 [L]

#Content Area
RewriteRule ^([^/.]+)$ index.php?uid=$1 [L]
RewriteRule ^([^/.]+)/page([^/.]+)$ index.php?uid=$1&page=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)/page([^/.]+)$ index.php?uid=$1&pid=$2&page=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/page([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3&page=$4 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)$ index.php?uid=$1&pid=$2&gid=$3&iid=$4 [L]

jdMorgan




msg:4263890
 9:11 pm on Feb 7, 2011 (gmt 0)

To fix the originally-posted problem, something like:

RewriteCond %{QUERY_STRING} ^m=h&page=([0-9])+(/page=[0-9]+)+$
RewriteRule ^$ http://www.example.com/top_rated/page%1 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^m=m&page=([0-9])+(/page=[0-9]+)+$
RewriteRule ^$ http://www.example.com/most_viewed/page%1 [R=301,L]

The posted code is far too long and has been re-posted too many times to get much sustained attention here. It could be significantly shortened (and sped up) by combing rules such as

RewriteRule ^category/$ http://www.example.com/category [R=301,L]
RewriteRule ^tag/$ http://www.example.com/tags [R=301,L]
... 28 more rules ...
RewriteRule ^blog/$ http://www.example.com/blog [R=301,L]
RewriteRule ^profile/$ http://www.example.com/profile [R=301,L] ]

into a single rule:

# Externally redirect to remove trailing slashes from all specified extensionless URL-paths
RewriteCond $1 ^(blog(_(drafts|queue))?category|tag|popular_tags|webmasters|contact|about|subscriptions|favorites|disabled|search-stats|(channel|title)-editor|seo-tools|import-(failed|profile|queued)|queued|most_(recent|viewed|discussed)|top_rated|featured|directory|search|stats|log(out|in)|lostpw|register)$
RewriteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]

or the much-less-efficient, but easier-to-maintain:

# Externally redirect requests for all URL-paths ending in "/" unless
# the requested URL-path resolves to a physically-existing directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]

In the first version, it is assumed that most requests to this server do not end in "/". Therefore, the specific URL-path testing is done in a separate RewriteCond, which will not be evaluated at all unless the (far simpler) RewriteRule pattern matches first (see mod_rewrite Rule Processing documentation for details).

The second version is less efficient because it calls the OS to go check the filesystem for each requested URL-path ending in a slash. This may require the physical disk to be checked, which is very slow (and hard on the disk if there are a lot of such checks). But you must decide whether that is a better or worse trade-off than maintaining this list of slashed URLs that need to be redirected to remove the slashes -- or not.

Jim

spunkle




msg:4265098
 10:42 am on Feb 10, 2011 (gmt 0)

Hi Jim,

I tried this with my htaccess but nothing changed...

RewriteCond %{QUERY_STRING} ^m=h&page=([0-9])+(/page=[0-9]+)+$
RewriteRule ^$ http://www.example.com/top_rated/page%1 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^m=m&page=([0-9])+(/page=[0-9]+)+$
RewriteRule ^$ http://www.example.com/most_viewed/page%1 [R=301,L]

any ideas?

jdMorgan




msg:4268601
 7:30 pm on Feb 17, 2011 (gmt 0)

  • Delete your browser cache.
  • Request www.example.com/?m=h&page=10/page=11 from your server.
  • You will be redirected to www.example.com/top_rated/page10

    If not, then either the rules are not in the right order, or the code is not designed to do what you need to do...

    Jim

  • Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / Code, Content, and Presentation / Apache Web Server
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved