Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} name=([-a-z0-9_]+)
RewriteRule ^book\.php$ http://www.example.com/book/%1? [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^book\.php$ http://www.example.com/book/%1? [R=301,L]
RewriteRule ^book\.php$ http://www.example.com/book/%1 [R=301,L]
this is added to the end of the URL ?cmtx_page=2#cmtx_comments
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} name=([-a-z0-9_]+)
RewriteRule ^book\.php$ http://www.example.com/book/%1? [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^book/([-a-z0-9_]+)$ /book.php?name=$1 [L]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 37.98.81.188
deny from 5.35.208.53
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://example.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.example.com$ [NC]
RewriteRule .*\.(zip|ace|rar|7z)$ http://www.example.com/no_hotlinking.htm [R,NC]
deny from 64.124.0.0/15
deny from 74.217.0.0/16
Options -Indexes
deny from 113.0.0.0/8
deny from 195.0.0.0/8
If I do bypass the mod_rewrite won't I lose the ability to have the static links?
www.example.com/book/book_name?cmtx_page=2#cmtx_comments
then the URL is page1
RewriteCond %{QUERY_STRING} cmtx_page=
RewriteRule ^blahblah - [L]
where "blahblah" represents the "path" part of any URL that can contain a discussion thread. (You need this part, instead of leaving it at . or ^ alone, so the server doesn't have to go look up conditions on every request ever.) This rule goes after any access-control RewriteRules, but before any rules that create an external redirect. RewriteCond %{QUERY_STRING} ^cmtx_page=1(&(.*))?$
RewriteRule ^(blahblah) http://www.example.com/$1?%2 [R=301,L]
which forcibly redirects any request for page1 back to the unpaginated form. That's assuming "cmtx_page" is always at the beginning of the query string, and that "page1" has no meaning.
RewriteCond %{QUERY_STRING} ^cmtx_page=1(&(.*))?$
RewriteRule ^(blahblah) http://www.example.com/$1?%2 [R=301,L] each "cmtx_page=2" to rewrite to /page/2 /page/3 etc.
RewriteRule ^book\.php$ http://www.example.com/book/%1 [R=301,L]
RewriteCond %{QUERY_STRING} ^cmtx_page=1(&(.*))?$
RewriteRule ^(blahblah) http://www.example.com/$1?%2 [R=301,L]
RewriteCondRewriteCond %{QUERY_STRING} cmtx_page
RewriteRule ^(blahblah) - [L]
where, again, "blahblah" is the path that all these queries are attached to. If it's always identical, like "book\.php", then you don't need to capture it. Just repeat the literal text on both sides, pattern and target. This pair of rules goes at the beginning of your external redirects-- that is, before the rule that redirects everything with a parameter. (The issue that started this whole thread.)