Forum Moderators: phranque
That is a duplicate url, i.e., if you remove the query string, the same url shows up. How do I remove it?
I've tried
RewriteCond %{QUERY_STRING} (.*)/(.*)fulll=1 [NC]
RewriteRule ^(.*)/(.*)$1? [R=301,L]
and it does not work
The command above it in .hatccess is the original rewrite command
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/([A-Za-z_0-9\-]+)$ /gallery/view_photo.php?set_albumName=$1&id=$2 [QSA]
the problem is with the end of that command id=$2
id is the picture name that can come out with either "picturename" or "picturename?full=1"
after view_photo.php? in the original rewrite there is the set_albumName=$1
which returns the url
/gallery/albumname/picture
also, I've been trying to hack the code in the gallery file for a week because I see exactly where the problem is,
------------------
if ($gallery->album->isResized($index) &&!$do_fullOnly) {
if ($full) {
echo "<a href=" . makeAlbumUrl($gallery->session->albumName, $id) . ">";
} else if ($gallery->user->canViewFullImages($gallery->album)) {
echo "<a href=" . makeAlbumUrl($gallery->session->albumName, $id, array("full" => 1)) . ">";
}
$openAnchor = 1;
---------------------
The problem is with the
---------------------------
echo "<a href=" . makeAlbumUrl($gallery->session->albumName, $id, array("full" => 1)) . ">";
---------------
even if you change that line of code to the original line
-------------------
if ($full) {
echo "<a href=" . makeAlbumUrl($gallery->session->albumName, $id) . ">";
-----------------
You will still be able to pick up the?full=1 string.
I figured the problem was not with the code but with the rewrite, because you can type in any query string after the url and it works
i.e., instead of having?full=1 at the end of the url, you can use?yourname=2167 or
?ilikemydog=45 and the url works
"I don't understand what you're trying to tell me",
reply: The entire second portion of the post referred to your comment about having to solve the problem in the script.
You also said,
"but the code I posted will strip "?full=1" from the end of any query string attached to gallery/view_photo.php and redirect, leaving the other query parameters as they were. (The variable %1 contains the query string that preceded "?full=1")"
ok, I understand that. I was mistaken to talk about the albumname
The problem is that view_photo.php was already rewritten in the previous command.
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/([A-Za-z_0-9\-]+)$ /gallery/view_photo.php?set_albumName=$1&id=$2 [QSA]
All of my photos are already rewritten to
^([^.\?/]+)/([A-Za-z_0-9\-]+)$
which means
gallery/albumname/picture
so, I'm trying to remove the string from
gallery/albumname/picture?full=1
not from
gallery/view_photo.php...?full=1
In that case, it's even simpler:
RewriteCond %{QUERY_STRING} .
RewriteRule ^gallery/([^/]+)/(.+)$ http://www.example.com/gallery/$1/$2? [R=301,L]
Jim
The solution, unfortunately did not work, and I tried a few variations on the theme.
Would the other rewrite conditions in .htaccess be the problem?
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/([0-9]+)$ /gallery/view_photo.php?set_albumName=$1&index=$2 [QSA]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/([A-Za-z_0-9\-]+)$ /gallery/view_photo.php?set_albumName=$1&id=$2 [QSA]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/$ /gallery/$1 [R]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)$ /gallery/view_album.php?set_albumName=$1 [QSA]
ErrorDocument 404 /error.php
DirectoryIndex index.php
php_value post_max_size 20971520
php_value upload_max_filesize 20971520
php_value magic_quotes_gpc off
php_flag session.bug_compat_warn off
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /gallery/
RewriteCond %{HTTP_HOST}!^example.com [NC]
RewriteRule ^(.*)$ http://example.com/gallery/$1 [R=301]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/([0-9]+)$ /gallery/view_photo.php?set_albumName=$1&index=$2 [QSA]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/([A-Za-z_0-9\-]+)$ /gallery/view_photo.php?set_albumName=$1&id=$2 [QSA]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)/$ /gallery/$1 [R]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^.\?/]+)$ /gallery/view_album.php?set_albumName=$1 [QSA]
RewriteCond %{QUERY_STRING} .
RewriteRule ^gallery/([^/]+)/(.+)$ http://example.com/gallery/$1/$2? [R=301,L]
</IfModule>
I'm wondering about that query string and others on all websites now.
For example, if you put?full=1 at the end of the url on this page
[webmasterworld.com...]
the page still shows up.
I tried it on many different pages around the net and it seems to work on over 90% of the pages. It even works for the New York Times.
So, it's not only my site. However, for my specific site, it is suppose to mean, view the image in "full" mode rather than view the image in resized mode.
Since I do not resize any of my images I do not use the "full view" option.
When I studied their listings of my site I found three big problems of duplicate content. Their spider went wild on my site creating a bunch of strange urls I never saw before.
I overhauled my entire site with new software and I've tried to make it duplicate free by using .htaccess, robots.txt, etc. This is the only issue I have not resolved.
Since Yahoo has not updated its SERPS for my site in over a month, I can not tell how well the fixes have worked. I can check urls and headers to see that they've worked on my side.