Post Reply 
Mod Rewrite / Link Headaches. Need help
02-Aug-2011, 08:57 AM
Post: #1
Mod Rewrite / Link Headaches. Need help
Hi and thanks for the great program and forum.

I have a script that uses Mod Rewrite for php and dynamic content so I was having some problems with integration. After going through the forum, I have managed to ALMOST get it all to work with my script. In the admin when I check the posted comment the page column shows.

http://www.mysite.comhttp://www.mysite.com/somehtmlpage.html

Is there anyway to strip away the first instance of http://www.mysite.com so that the link will be correct and show up on the correct page of my site?

I have tried every combination of $page_id and $reference that I can possibly think of and I have only been able to get the results above using the following combination and only in the following order.

$reference="http://".$_SERVER['HTTP_HOST'].$_SERVER['HTTP_REFERER'];
$page_id = "cmtx_title".$_SERVER['HTTP_REFERER'];

If there is any php code that can be used to filter the result before posting to the database table or some other nifty suggestion anyone has, I would really appreciate it.
Find all posts by this user
Quote this message in a reply
02-Aug-2011, 11:58 AM
Post: #2
RE: Mod Rewrite / Link Headaches. Need help
Hi,

The correct way to retrieve the full URL of the page would be like this:
PHP Code:
$reference "http" . ((!empty($_SERVER['HTTPS'])) ? "s" "") . "://" $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 

Note that typing "cmtx_url" would give the same result as above, like this:
PHP Code:
$reference "cmtx_url"

Also, when entering keywords like "cmtx_url" and "cmtx_title", it needs to be only the keyword there and nothing else. For example the first line of code will not work properly because it has an extra bit of text to it whereas the second will work as expected:

PHP Code:
$page_id "cmtx_title" $_SERVER['HTTP_REFERER']; 

PHP Code:
$page_id "cmtx_title"

You can correct any existing values by editing the relevant page in Manage -> Pages.

I hope that helps.

Have you completed the interview?
Find all posts by this user
Quote this message in a reply
02-Aug-2011, 08:42 PM
Post: #3
RE: Mod Rewrite / Link Headaches. Need help
Hi Steven,

Thank you for your reply your answer led me to a better understanding of the problem I'm having so it was indeed helpful.

Here is what is occuring: When the web page where the comments form is displayed loads I have a URL http://www.somewebsite.com/somefile.html

I enter some comments to complete the form and click Add Comments and
the Comment Added message is displayed but the URL has changed to
http://www.somewebsite.com/viewhtml?j=1162#form

When I check the database I can see that there are two entries in the pages site. One entry is for the http://www.somewebsite.com/somefile.html
and the other for the http://www.somewebsite.com/viewhtml?j=1162#form

comments appear only on the second page ( http://www.somewebsite.com/viewhtml?j=1162#form)

Is there anything you can think of that will allow me to have comments appear only on this first page? Im not sure if I need to make a modification to Commentics or a modification to my script, but if there is anyone that can lead me to a solution I would be appreciative!
Find all posts by this user
Quote this message in a reply
02-Aug-2011, 09:04 PM
Post: #4
RE: Mod Rewrite / Link Headaches. Need help
Hi,

Okay I understand the issue now. It's similar to this thread. As suggested there, in /comments/includes/template/form.php and /comments/includes/functions/comments.php, can you try replacing every occurrence of:
PHP Code:
htmlentities($_SERVER['PHP_SELF']) 

With:
PHP Code:
htmlentities(strtok($_SERVER['REQUEST_URI'], "?")) 

By the way I will be upgrading this forum software within the next couple of hours so it will be in maintenance mode for a short period of time.

Have you completed the interview?
Find all posts by this user
Quote this message in a reply
03-Aug-2011, 05:31 PM
Post: #5
RE: Mod Rewrite / Link Headaches. Need help
Yesssss! that fixed it. I had actually tried that at one point a day or two ago but I must have missed a replace somewhere because now everything is working like a charm. Thank you again for the help and for your excellent project! It really is superior to all of the other comment scripts I tested. Smile

(02-Aug-2011 09:04 PM)Steven Wrote:  Hi,

Okay I understand the issue now. It's similar to this thread. As suggested there, in /comments/includes/template/form.php and /comments/includes/functions/comments.php, can you try replacing every occurrence of:
PHP Code:
htmlentities($_SERVER['PHP_SELF']) 

With:
PHP Code:
htmlentities(strtok($_SERVER['REQUEST_URI'], "?")) 

By the way I will be upgrading this forum software within the next couple of hours so it will be in maintenance mode for a short period of time.

RolleyesRolleyes
Find all posts by this user
Quote this message in a reply
04-Aug-2011, 03:37 PM
Post: #6
RE: Mod Rewrite / Link Headaches. Need help
Hi,

Thanks, I'm glad you like the script, and I appreciate your feedback that the solution above worked for you.

Have you completed the interview?
Find all posts by this user
Quote this message in a reply
05-Aug-2011, 05:20 AM
Post: #7
Question RE: Mod Rewrite / Link Headaches. Need help
(02-Aug-2011 11:58 AM)Steven Wrote:  Hi,

The correct way to retrieve the full URL of the page would be like this:
PHP Code:
$reference "http" . ((!empty($_SERVER['HTTPS'])) ? "s" "") . "://" $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 

Note that typing "cmtx_url" would give the same result as above, like this:
PHP Code:
$reference "cmtx_url"

Also, when entering keywords like "cmtx_url" and "cmtx_title", it needs to be only the keyword there and nothing else. For example the first line of code will not work properly because it has an extra bit of text to it whereas the second will work as expected:

PHP Code:
$page_id "cmtx_title" $_SERVER['HTTP_REFERER']; 

PHP Code:
$page_id "cmtx_title"

You can correct any existing values by editing the relevant page in Manage -> Pages.

I hope that helps.

Change everything per your instruction, and it's work, but work if i insert just like this:
<?php
$page_id = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$reference = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$path_to_comments_folder = "comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
?>

but if change this part "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
to
cmtx_title or cmtx_url;
it's stop work and page start loading about 5-10 min, on page where comments implemented display half of page.

Please help fix it.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-Aug-2011, 09:08 PM
Post: #8
RE: Mod Rewrite / Link Headaches. Need help
Hi,

The 'cmtx_title' keyword will only work if your server is configured properly (either cURL or fopen(URL) need to be available). The installer will have stated whether they are or not. The problem could also be due to the webpage being unresponsive. One thing you could do is to try to produce an error message.

Also can you post the integration code that you are having an issue with.

Have you completed the interview?
Find all posts by this user
Quote this message in a reply
06-Aug-2011, 12:12 AM
Post: #9
RE: Mod Rewrite / Link Headaches. Need help
On my server enabled both cURL and fopen(URL)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Improper Link to Initiate a Reply rlfcycle 0 218 12-Feb-2012 03:15 AM
Last Post: rlfcycle

Forum Jump:


User(s) browsing this thread: 1 Guest(s)