Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine on
RewriteMap newurl prg://var/www/cgi-bin/cleanup.php
RewriteRule ^/((?i).*-aa$) ${newurl:$1} [L]
RewriteLock /var/lock/mapexample.lock #!/usr/bin/php
<?php
include '/var/www/vhosts/example.com/path-to-database-connection-file';
set_time_limit(0);
$keyboard = fopen("php://stdin","r");
while (1) {
$line = fgets($keyboard);
if (preg_match('/(.*)/', $line, $igot)) {
$getalias = mysql_query("select cc FROM `database`.`table` WHERE slug = '$igot[1]'");
while($row=mysql_fetch_array($getalias)) {
$arid = $row['cc'];
}
print "/asdfasdf/asdfasdf.php?cc=$arid\n";
}
else {
print "$line\n";
}
}
?> Options +FollowSymlinks
RewriteEngine on
#use the built in apache function for converting to lowercase
RewriteMap lc int:tolower
#look only at requests that end in -aa
RewriteCond %{REQUEST_URI} (.*)-(?i)aa$
#look only at requests that have at least one capital letter
RewriteCond %{REQUEST_URI} [A-Z]
#look only at requests that are not in a directory (so only the root folder,
#knowing the form of all the URL's as shown above, and again,
#this is the request from the browser, not the file we want to appear.
RewriteCond %{REQUEST_URI} !^(.+?)/
#take anything that meets all of the above, and send it to the built in
#apache lowercase map as a 301 redirect.
RewriteRule ^/(.*) ${lc:$1} [R=301] RewriteMap newurl prg://var/www/cgi-bin/cleanup.php
RewriteCond %{REQUEST_URI} !^(.+?)/
RewriteRule ^/((?i).*-aa$) ${newurl:$1}
Options -Indexes +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
RewriteCond %{http_host} !^example$ [nc]
RewriteRule ^(.*)$ http://example/$1 [r=301,nc,L]
#look only at requests that end in -aa
RewriteCond %{REQUEST_URI} (.*)-(?i)aa$
#look only at requests that have at least one capital letter
RewriteCond %{REQUEST_URI} [A-Z]
#look only at requests that are not in a directory (so only the root folder,
#knowing the form of all the URL's as shown above, and again,
#this is the request from the browser, not the file we want to appear.
RewriteCond %{REQUEST_URI} !^(.+?)/
#take anything that meets all of the above, and send it to the built in
#apache lowercase map as a 301 redirect.
RewriteRule ^/(.*) ${lc:$1} [R=301]
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
RewriteCond %{http_host} !^example$ [nc]
RewriteRule ^(.*)$ http://example/$1 [r=301,nc,L]
Options +FollowSymlinks
RewriteEngine on
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} !^(.+?)/ #must be in root, not a directory
RewriteCond %{REQUEST_URI} -(?i)bb$ #end in -bb (case no matter)
RewriteCond %{REQUEST_URI} [A-Z] #has a capital letter
RewriteRule ^/(.*) ${lc:$1} [R=301,L] #anything that survives the three conditions, send it to the lowercase map as a 301 to a lowercase URI
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/ #four lines to deal with removing index.php and www via 301
RewriteRule ^/(.*)index\.php$ /$1 [R=301,L]
RewriteCond %{http_host} !^example.com$ [nc]
RewriteRule ^/(.*)$ http://example.com/$1 [r=301,nc,L]
RewriteMap mapfest dbm:/folder2/on-server/map.dbm #define map name and type and pinpoint the location of the file ( the name of the map is mapfest, the file is map.dbm)
RewriteCond %{REQUEST_URI} !^(.+?)/ #incoming URL must be in root, not a directory
RewriteCond ${mapfest:$1|NOT_FOUND} !NOT_FOUND [NC] #NOT_FOUND is something that does not match anything in the map.
#So if !NOT_FOUND (not NOT_FOUND, or more simply if it's found in the map), send it to the map.
#If it is NOT_FOUND, don't send it to the map. This looks forward into the map and only sends requests that will match.
RewriteRule ^/(.*) /folder/file.php?Item_Num=${mapfest:$1|NOT_FOUND} [L] #anything gets here, pull the match
#from the map and append it to the target path as shown. Show that file, but leave the URL in the address bar alone. DELIMITER //
CREATE PROCEDURE nameofstoredprocedure()
BEGIN
SELECT slug,ItemID FROM TABLE WHERE various like this and not like thats GROUP BY slug into outfile '/folder1/on-server/map.txt' Lines terminated by '\n';
END //
DELIMITER ; mysql -h example.com -u youruser name -pyourpassword -D nameofdatabase -e 'CALL nameofstoredprocedure()' #call the stored procedure from cron, no script needed, just this command, and no space after the -p …you need the -p, just no space after it, a space you do need with the -u, the -D, the -e and the word CALL
/usr/sbin/httxt2dbm -i /folder1/on-server/map.txt -o /folder1/on-server/map.dbm #convert the created txt file to a dbm hash file - well, it actually makes two files as shown next
cp /folder1/on-server/map.dbm.dir /folder2/on-server/map.dbm.dir #copy and paste hash file to from folder 1 to folder2
cp /folder1/on-server/map.dbm.pag /folder2/on-server/map.dbm.pag #copy and paste hash file to from folder 1 to folder2
rm -f /folder1/on-server/map.txt #delete txt file
rm -f /folder1/on-server/map.dbm.dir #delete hash file
rm -f /folder1/on-server/map.dbm.pag #delete hash file