question mark is incorrectly removed from end of url

New to mod_rewrite? This is a good place to start.

question mark is incorrectly removed from end of url

Postby osaka73 » Thu Oct 08, 2009 5:41 am

I have a string after my URL.
ex: forum.html?mark=read

But in some instances the question mark is being removed resulting in forum.htmlmark=read

To be more exact, this is what I have in my .htaccess:
Code: Select all
RewriteEngine on
# Fix bookmarks
RewriteRule ^(.*\.html[-]?)\&(.*)$      http://www.somedomain.com/forums/$1?$2      [R=301,NC,L]


# Fix google indexed data
RewriteRule ^post-(.+).html$            http://www.somedomain.com/forums/viewtopic.php?p=$1      [R=301,NC,L]
RewriteRule ^about(.+).html$            http://www.somedomain.com/forums/viewtopic.php?t=$1      [R=301,NC,L]
RewriteRule ^forum-(.+).html$            http://www.somedomain.com/forums/viewforum.php?f=$1      [R=301,NC,L]

# Apply current SEO mod
Rewriterule ^(.+)-f([0-9]*).html-(.+)$            ./viewforum.php?f=$2&$3
Rewriterule ^(.+)-(t|p)([0-9]*).html-(.+)$         ./viewtopic.php?$2=$3&$4
Rewriterule ^(.+)-f([0-9]*)s([0-9]*).html-(.+)$      ./viewforum.php?f=$2&start=$3&$4
Rewriterule ^(.+)-(t|p)([0-9]*)s([0-9]*).html-(.+)$   ./viewtopic.php?$2=$3&start=$4&$5

Rewriterule ^(.+)-f([0-9]*).html$               ./viewforum.php?f=$2&$3
Rewriterule ^(.+)-(t|p)([0-9]*).html$            ./viewtopic.php?$2=$3&$4
Rewriterule ^(.+)-f([0-9]*)s([0-9]*).html$         ./viewforum.php?f=$2&start=$3&$4
Rewriterule ^(.+)-(t|p)([0-9]*)s([0-9]*).html$      ./viewtopic.php?$2=$3&start=$4&$5


The two exact problems are:
Code: Select all
http://www.somedomain.com/forums/support-f100.htmlsk=t&sd=d
(missing question mark after html)
http://www.somedomain.com/forums/support-f100.htmlmark=topics
(missing question mark after html)


I could really use some help on resolving this, as it's creating so many page not found errors. Thanks in advance for any direction, advice, or solutions.
osaka73
 
Posts: 4
Joined: Thu Oct 08, 2009 5:08 am

Re: question mark is incorrectly removed from end of url

Postby DanielStutzbach » Thu Oct 08, 2009 6:44 am

osaka73 wrote:The two exact problems are:
Code: Select all
http://www.somedomain.com/forums/support-f100.htmlsk=t&sd=d
(missing question mark after html)
http://www.somedomain.com/forums/support-f100.htmlmark=topics
(missing question mark after html)



Do you know what the URLS were originally, that are being redirected to those incorrect URLs?
DanielStutzbach
 
Posts: 6
Joined: Wed Aug 19, 2009 6:49 am

Postby osaka73 » Thu Oct 08, 2009 7:00 am

I think so.

Code: Select all
http://www.somedomain.com/forums/viewforum.php?f=100&sk=t&sd=d

and

http://www.somedomain.com/forums/viewforum.php?f=100&mark=topics


I actually tried these original urls on my domain, and they both worked correctly, so I'm pretty positive that the above are the original URLs.
osaka73
 
Posts: 4
Joined: Thu Oct 08, 2009 5:08 am

Postby richardk » Thu Oct 08, 2009 11:02 am

What are the links like in the page's HTML source code? Do they have a ? in them?

Code: Select all
Options +FollowSymlinks

RewriteEngine On

# Fix bookmarks
RewriteRule ^(.+\.html-?)\&(.+)$ http://www.example.com/forums/$1?$2 [NC,R=301,L]

# Fix google indexed data
RewriteRule ^post-(.+)\.html$  http://www.example.com/forums/viewtopic.php?p=$1 [NC,R=301,L]
RewriteRule ^about(.+)\.html$  http://www.example.com/forums/viewtopic.php?t=$1 [NC,R=301,L]
RewriteRule ^forum-(.+)\.html$ http://www.example.com/forums/viewforum.php?f=$1 [NC,R=301,L]

# Apply current SEO mod
RewriteRule ^.+-f([0-9]+)\.html(-(.+))?$              ./viewforum.php?f=$1&$3           [QSA,L]
RewriteRule ^.+-(t|p)([0-9]+)\.html(-(.+))?$          ./viewtopic.php?$1=$2&$4          [QSA,L]
RewriteRule ^.+-f([0-9]+)s([0-9]+)\.html(-(.+))?$     ./viewforum.php?f=$1&start=$2&$4  [QSA,L]
RewriteRule ^.+-(t|p)([0-9]+)s([0-9]+)\.html(-(.+))?$ ./viewtopic.php?$1=$2&start=$3&$5 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby osaka73 » Thu Oct 08, 2009 11:12 am

No. Even in the source code, they are like this:

Code: Select all
./support-f100.htmlsk=t&sd=d
./support-f100.htmlmark=topics
osaka73
 
Posts: 4
Joined: Thu Oct 08, 2009 5:08 am

Postby richardk » Thu Oct 08, 2009 12:17 pm

Then the problem is the PHP outputting the link not the mod_rewrite.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby osaka73 » Thu Oct 08, 2009 5:01 pm

Thank you so much! I would have spent hours trying to figure out where my mod_rewrite had gone wrong.

I focused my direction on the php output, and found the problems.

Not sure anybody else will find my post helpful, except for the fact that they might look at the code above and see it is correct.

Thanks again.
osaka73
 
Posts: 4
Joined: Thu Oct 08, 2009 5:08 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 6 guests

cron