Forum Moderators: phranque
https://www.domain.com/detail/1000-COMPANYNAME-Category-_-Sub_Category-Name-_-AAA123-01.html https://www.domain.com/gallery/Images/Category/AAA/COMPANYNAME%20Category%20-%20Sub%20Category%20Name%20-%20AAA123%2001.jpg # PHP 5.2
AddType application/x-httpd-php52 .php
RewriteEngine On
# block some habitual hotlinkers
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?gensun\.org/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?beling\.net/ [NC]
RewriteRule .*\.(jpg|gif|bmp|png)$ [F]
<Files .htaccess>
order allow,deny
deny from all
</Files>
########## Begin - Rewrite rules to block out some common exploits
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
Options FollowSymLinks
RewriteRule ^(.*)$ index.php [F,L]
########## End - Rewrite rules to block out some common exploits
RewriteRule ^(others)(.*)(.html|htm)$ $1$2$3 [NC,L]
RewriteRule ^(help)(.htm)$ $1$2 [NC,L]
RewriteRule ^(help_menu)(.htm)$ $1$2 [NC,L]
RewriteRule ^(help_contents)(.htm)$ $1$2 [NC,L]
RewriteRule ^(installation)(.html)$ $1$2 [NC,L]
RewriteRule ^(resultC)(.html)$ $1$2 [NC,L]
RewriteRule ^(resultY)(.html)$ $1$2 [NC,L]
RewriteRule ^(secure-hosting-htmlbad)(.html)$ $1$2 [NC,L]
RewriteRule ^(secure-hosting-htmlgood)(.html)$ $1$2 [NC,L]
RewriteRule ^(secure-hosting-template)(.html)$ $1$2 [NC,L]
RewriteRule ^(wtc_service)(.htm)$ $1$2 [NC,L]
RewriteRule ^(images)(.*)(.html|htm)$ $1$2$3 [NC,L]
RewriteRule ^(logout_private)/(.*).html$ logout.php?from=private_gallery.php&mode=$2 [NC,L]
RewriteRule ^(.*[\/])(logout_private)/(.*).html$ logout.php?from=private_gallery.php&mode=$3 [NC,L]
RewriteRule ^(logout_private.html)$ logout.php?from=private_gallery.php&mode=1 [NC,L]
RewriteRule ^(cb.html)$ cb.php [NC,L]
RewriteRule ^(login.html)$ user_login.php [NC,L]
RewriteRule ^(private_gallery.html)$ private_gallery.php [NC,L]
RewriteRule ^(index|logout)/(.*)?$ $1.php?link=$2 [NC,L]
RewriteRule ^(index)$ index.php [NC,L]
RewriteRule ^(index\/+)$ index.php [NC,L]
#new seo urls
RewriteRule ^(.*[\/])logout.html$ logout.php?from=index.php [NC,L]
RewriteRule ^logout.html$ logout.php?from=index.php [NC,L]
RewriteRule ^(rss[\/])(.*)(\.html)?$ rss.php?arg=$1$2 [NC,L]
RewriteRule ^(.*[\/])(rss[\/])(.*)(\.html)?$ rss.php?arg=$1$2$3 [NC,L]
RewriteRule ^register.html$ register.php [NC,L]
RewriteRule ^(.*[\/])(register.html)$ register.php?arg=$1$2 [NC,L]
RewriteRule ^((.*)\.html)?$ index.php?arg=$1 [NC,L]
RewriteRule ^(cms[\/])(.*)?$ index.php?arg=$1$2 [NC,L]
RewriteRule ^(.*[\/])(cms[\/])(.*)?$ index.php?arg=$1$2$3 [NC,L]
RewriteRule ^(.*[\/])search[\/]?$ index.php?arg=$1search/index.html [NC,L]
RewriteRule ^(.*[\/])search?$ index.php?arg=$1search/index.html [NC,L]
RewriteRule ^search[\/]?$ index.php?arg=search/index.html [NC,L]
RewriteRule ^search?$ index.php?arg=search/index.html [NC,L]
RewriteRule ^(.*[\/])new_media[\/]?$ index.php?arg=$1new_media/index.html [NC,L]
RewriteRule ^(.*[\/])new_media?$ index.php?arg=$1new_media/index.html [NC,L]
RewriteRule ^new_media[\/]?$ index.php?arg=new_media/index.html [NC,L]
RewriteRule ^new_media?$ index.php?arg=new_media/index.html [NC,L]
RewriteRule ^(.*[\/])popular[\/]?$ index.php?arg=$1popular/index.html [NC,L]
RewriteRule ^(.*[\/])popular?$ index.php?arg=$1popular/index.html [NC,L]
RewriteRule ^popular[\/]?$ index.php?arg=popular/index.html [NC,L]
RewriteRule ^popular?$ index.php?arg=popular/index.html [NC,L]
RewriteRule ^(.*[\/])lightbox[\/]?$ index.php?arg=$1lightbox/index.html [NC,L]
RewriteRule ^(.*[\/])lightbox?$ index.php?arg=$1lightbox/index.html [NC,L]
RewriteRule ^lightbox[\/]?$ index.php?arg=lightbox/index.html [NC,L]
RewriteRule ^lightbox?$ index.php?arg=lightbox/index.html [NC,L]
RewriteRule ^(.*[\/])news[\/]?$ index.php?arg=$1news/index.html [NC,L]
RewriteRule ^(.*[\/])news?$ index.php?arg=$1news/index.html [NC,L]
RewriteRule ^news[\/]?$ index.php?arg=news/index.html [NC,L]
RewriteRule ^news?$ index.php?arg=news/index.html [NC,L]
RewriteRule ^(.*[\/])portfolio[\/]?$ index.php?arg=$1portfolio/index.html [NC,L]
RewriteRule ^(.*[\/])portfolio?$ index.php?arg=$1portfolio/index.html [NC,L]
RewriteRule ^portfolio[\/]?$ index.php?arg=portfolio/index.html [NC,L]
RewriteRule ^portfolio?$ index.php?arg=portfolio/index.html [NC,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
#RewriteRule ^(.*)\.html?$ index.php?arg=$1.html [NC,L]
ErrorDocument 400 /errors/400.shtml
ErrorDocument 401 /errors/401.shtml
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
ErrorDocument 500 /errors/500.shtml https://www.domain.com/detail/5637-COMPANYNAME-Category-_-Sub_Category-Name-_-AAA123-01.html https://www.domain.com/detail/5637-companyname-category-sub-category-name-AAA123-01.html https://www.domain.com/gallery/COMPANYNAME Category - Sub-Category Name - AAA123 01.jpg https://www.domain.com/gallery/companyname-category-sub-category-name-AAA123-01.jpg https://www.domain.com/detail/5637-COMPANYNAME-Category-_-Sub_Category-Name-_-AAA123-01.html
RewriteRule [_-] /fixup.php [L] site.com/detail/12345-COMPANYNAME-Imagepack-_-Word-Word-Word-ABC123.html
and
site.com/detail/12346-COMPANYNAME-Category-_-Word-Word-_-ABC123-01.html
/detail/\d{5}-COMPANYNAME-\w{2,}-_-\w{2,}-\w{2,}-\w{2,}-\w{2,}\.html
and
/detail/\d{5}-COMPANYNAME-\w{2,}-_-\w{2,}-\w{2,}-_-\w{2,}-\d{2}\.html Word-Word-Word <- always there but a variable number of words.
You said above that it's "superficially a rewrite" rather than redirect.. Does this mean that the database side of things doesn't have to be changed?
only this time you needn't bother about an external redirect (because the image files have no visible existence to the world at large, right?).
URLs which have one instance of -_- and URLs which have two instances of -_-
RewriteRule ^([^_]+)-_-([^_]+)-_-([^_]+)-_-([^_]+)$ http://www.example.com/$1-$2-$3-$4 [R=301,L]
RewriteRule ^([^_]+)-_-([^_]+)-_-([^_]+)$ http://www.example.com/$1-$2-$3 [R=301,L]
RewriteRule ^([^_]+)-_-([^_]+)$ http://www.example.com/$1-$2 [R=301,L]