Forum Moderators: phranque
I tried the following: Redirect 301 /Qstore/Qstore.cgi http://example.com/store/index.php
but it simply adds the part of the url after? to the end of the new url, i.e. http://example.com/store/index.php?CMD=011&PROD=1143909939
So then I tried:
RewriteRule ^Qstore/Qstore\.cgi\?[.]$ http://example.com/store/index.php [R=301,L]
but it doesn't work. I need to redirect any page in the old Qstore/Qstore.cgi directory to store/index.php...how would I do this? Thanks!
RewriteRule ^Qstore/Qstore\.cgi\?[.]$ http://example.com/store/index.php [R=301,L]
if i got this right, it should look for ...Qstore.cgi followed by a possible "?" and some possible characters following that to end the string.
However, in this case, since all you want to do is to remove the query, just add a "?" to the end of your substitution URL:
RewriteRule ^Qstore/Qstore\.cgi$ http://example.com/store/index.p[b]hp?[/b] [R=301,L]
One more note: You can even create URLs in the substitution string containing a query string part. Just use a question mark inside the substitution string to indicate that the following stuff should be re-injected into the QUERY_STRING. When you want to erase an existing query string, end the substitution string with just the question mark.(emphasis added)
Jim
I tried to use the rule you provided earlier to get of stubborn? marks in some remaining urls, but it doesn't seem to work if there's no query string after it:
RewriteRule ^photos/washington-dc/$ http://example.com/photos/washington-dc/? [R=301,L]
RewriteRule ^photos/washington-dc/\?$ http://example.com/photos/washington-dc/ [R=301,L]
RewriteRule ^photos/washington-dc/?$ http://example.com/photos/washington-dc/ [R=301,L]
none of these stripped the? mark off the end of the url. Can urls with one? at the end and no quesry string be constued as a differnt URL tby the SEs? I.e.:
example.com/photos/washington-dc/? and
example.com/photos/washington-dc/
Thanks
See jdMorgan's post above. You will need to use a query_string condition to see if there is a query_string. IWO \? will not match the URL ending in ?.
To remove the query_string from all pages only when there IS A QUERY_STRING:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
Hope this Helps.
Justin
I'd suggest:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /photos/washington-dc/\?\ HTTP/
RewriteRule ^photos/washington-dc/$ http://www.example.com/photos/washington-dc/? [R=301,L]
Please post the results, as this is an odd boundary condition, and needs to go into my "remember this" list...
Jim
I would suggest both using the code --if you can get it working-- and fixing the origin of the problem. Using the code will speed corrections in the search results (if those bad URLs are indexed).
Jim
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI}!/index\.php$
RewriteRule . - [L]
RewriteCond %{QUERY_STRING} view=core.DownloadItem
RewriteCond %{QUERY_STRING} itemId=([0-9]+)
RewriteCond %{HTTP_REFERER}!://example.com/ [NC]
RewriteCond %{HTTP_REFERER}!^$
RewriteRule . /index.php?g2_view=rewrite.DownloadItem&g2_itemId=%1 [L]
RewriteCond %{THE_REQUEST} \ /sitemap(\?.¦\ .)
RewriteCond %{REQUEST_URI}!/index\.php$
RewriteRule . /index.php?g2_view=sitemap.Sitemap [QSA,L]
RewriteCond %{THE_REQUEST} \ /photos/([^?]+)/([0-9]*)(\?.¦\ .)
RewriteCond %{REQUEST_URI}!/index\.php$
RewriteRule . /index.php?g2_view=core.ShowItem&g2_path=%1&g2_page=%2 [QSA,L]
RewriteCond %{THE_REQUEST} \ /d/([^\/\?]+)(\?.¦\ .)
RewriteCond %{REQUEST_URI}!/index\.php$
RewriteRule . /index.php?g2_view=core.DownloadItem&g2_fileName=%1 [QSA,L]
</IfModule>
# END Url Rewrite section