Hello,
I'm writing the custom rewrite rules to generate an seo friendly urls, for that created file into conf folder says k.php and passed the parameters to httpd.conf as fallows but it is not working. Please help me to track this issue.
Old URL: [
domain.com...]
New URL Wanted: [
domain.com...]
The php file with name is: k.php
-----------------------------------------------------------------
<?php
# PHP/MySQL db connection
$hostname_conn_ht = "127.0.0.1";
$database_conn_ht = "dbname";
$username_conn_ht = "username";
$password_conn_ht = "password";
$conn_ht = mysql_pconnect($hostname_conn_ht, $username_conn_ht, $password_conn_ht);
mysql_select_db($database_conn_ht, $conn_ht);
# this program cannot die ... TO DO: graceful error handling needed
set_time_limit(0);
error_log ('your_content', 3, 'k.log');
# assign STDIN to handler
$keyboard = fopen("php://stdin","r");
# always
while (1) {
# read STDIN to variable from handler
$line = fgets($keyboard);
error_log ($line, 3, 'k.log');
# check for string '/chars/chars/' in URI
if (preg_match('/(.*)\/(.*)/', $line, $igot)) {
$getalias = mysql_query("SELECT id FROM `krd_community_groups` WHERE name = 'mpleague'");
while($row=mysql_fetch_array($getalias)) {
$arid = $row['id'];
print "test\n";
error_log ('test', 3, 'k.log');
}
# print dynamic resource reference to STDOUT (does not refresh URI in address bar)
print "https://www.domain.com/my-team-league/viewgroup/$arid-MPLeague\n";
error_log ('test6', 3, 'k.log');
}
else {
# did not match '/chars/chars/', so just use the original URI (i.e. 'about.html')
print "$line\n";
}
}
?>
---------------------------------------------------------------
Following is the httpd.conf file where i'm trying to making rewrite rules but it don't working help me to work it please.
The htaccess rewrite map is used here and call to the k.php file to getting query results into httpd.conf. please help me to fix this.
httpd.conf
# Include "/opt/bitnami/apache2/conf/ssi.conf"
AddType application/x-httpd-php .php
PHPIniDir "/opt/bitnami/php/etc"
Include "conf/deflate.conf"
Include "/opt/bitnami/apache2/conf/bitnami/bitnami.conf"
# Include "/opt/bitnami/apps/django/conf/django.conf"
# Include conf/bitnami/passenger.conf
Include "/opt/bitnami/apache2/conf/bitnami/httpd.conf"
RewriteEngine on
RewriteMap grp prg:/opt/bitnami/apache2/conf/k.php
RewriteCond %{REQUEST_URI} ^/league
RewriteRule ^/(.*) ${grp:$1} [L]
#RewriteMap leagues txt:/opt/bitnami/apache2/conf/leagues.txt