How to cut question mark with htaccess

serpent_driver

Well-Known Member
#2
Why do you publish data to access your server? Are you crazy?

Try this for your question. Not tested, but should work:

Code:
RewriteCond %{QUERY_STRING} (.*)\?(.*)$
RewriteRule ^(.*)$ $1\?%1%2 [R=301,L,NE]

RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ $1%1? [R=301,L,NE]
 
#5
Like this now

Code:
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
AddType image/vnd.microsoft.icon .cur
ExpiresByType application/pdf "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType image/vnd.microsoft.icon "access 1 year"
ExpiresByType image/svg+xml "access 1 year"

ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/webp "access 1 year"

ExpiresByType video/ogg "access 1 year"
ExpiresByType audio/ogg "access 1 year"
ExpiresByType video/mp4 "access 1 year"
ExpiresByType video/webm "access 1 year"

ExpiresByType text/css "access 1 year"
ExpiresByType text/javascript "access 1 year"
ExpiresByType application/javascript "access 1 year"
ExpiresByType application/x-javascript "access 1 year"

ExpiresByType application/x-font-ttf "access 1 year"
ExpiresByType application/x-font-woff "access 1 year"
ExpiresByType application/font-woff "access 1 year"
ExpiresByType application/font-woff2 "access 1 year"
ExpiresByType application/vnd.ms-fontobject "access 1 year"
ExpiresByType font/ttf "access 1 year"
ExpiresByType font/woff "access 1 year"
ExpiresByType font/woff2 "access 1 year"

</IfModule>
### marker BROWSER CACHE end ###

<IfModule mod_headers.c>
    # X-Frame-Options
    Header always set X-Frame-Options "SAMEORIGIN"
    # X-XSS-Protection
    Header always set X-XSS-Protection "1; mode=block"
    # X-Content-Type-Options
    Header always set X-Content-Type-Options nosniff
    # Referrer-Policy
    Header always set Referrer-Policy "origin-when-cross-origin"
    # Feature Policy
    # Header set Feature-Policy "geolocation 'none'; midi 'none'; camera 'none'; usb 'none'; magnetometer 'none'; accelerometer 'none'; gyroscope 'none'; microphone 'none'"
    #Set secure cookies
    #Header always set Set-Cookie HttpOnly;Secure
    # Strict Transport Security Policy
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" env=HTTPS
    
  Header always set Vary "Accept-Encoding"

  <FilesMatch "\.(png|jpg|ico|zip|rar|dat|ttf|woff|cur)$">
    Header unset Vary
  </FilesMatch>
 
    <FilesMatch "(disqus\.php|amp\-helper\-frame\.html|amp\-permission\-dialog\.html)">
    Header unset X-Frame-Options
    </FilesMatch>

</IfModule>

AddDefaultCharset UTF-8
ErrorDocument 403 /403.shtml

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "CloudFlare-AlwaysOnline" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "python-requests" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "MJ12bot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^CCBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Zend_Http_Client" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Apache-HttpClient" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "SeopultContentAnalyzer" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "linkfluence\.com" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "ips-agent" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "evc-batch" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "PicoFeed" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "svetabot\.online" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Scrapy" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Wget/" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^curl/" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "SEOkicks" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "SiteCheckerBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Dataprovider" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "AwarioSmartBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "BLEXBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "AspiegelBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "GuzzleHttp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "woorankreview" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "StolenCameraFinder-Discovery" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "NetpeakCheckerBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "MauiBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "DomCopBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Riddler" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "newspaper" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "MTRobot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Barkrowler" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "DataForSeoBot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Uptime monitoring" [NC,OR]
RewriteCond %{HTTP_REFERER} "shoptxt\.ru" [NC,OR]
RewriteCond %{HTTP_REFERER} "^https?://(?:[^/]+\.)?site\.ru" [NC,OR]
RewriteCond %{HTTP_REFERER} "whalesasian\.com" [NC]
RewriteRule ^.* - [F,L]
</IfModule>

## USER AGENT BANING
SetEnvIfNoCase User-Agent .*rogerbot.* bad_bot
SetEnvIfNoCase User-Agent .*exabot.* bad_bot
SetEnvIfNoCase User-Agent .*dotbot.* bad_bot
SetEnvIfNoCase User-Agent .*gigabot.* bad_bot
SetEnvIfNoCase User-Agent .*ahrefsbot.* bad_bot
SetEnvIfNoCase User-Agent .*sitebot.* bad_bot
SetEnvIfNoCase User-Agent .*semrushbot.* bad_bot
SetEnvIfNoCase User-Agent .*ia_archiver.* bad_bot
SetEnvIfNoCase User-Agent .*searchmetricsbot.* bad_bot
SetEnvIfNoCase User-Agent .*seokicks-robot.* bad_bot
SetEnvIfNoCase User-Agent .*sistrix.* bad_bot
SetEnvIfNoCase User-Agent .*lipperhey spider.* bad_bot
SetEnvIfNoCase User-Agent .*ncbot.* bad_bot
SetEnvIfNoCase User-Agent .*backlinkcrawler.* bad_bot
SetEnvIfNoCase User-Agent .*meanpathbot.* bad_bot
SetEnvIfNoCase User-Agent .*pagesinventory.* bad_bot
SetEnvIfNoCase User-Agent .*aboundexbot.* bad_bot
SetEnvIfNoCase User-Agent .*spbot.* bad_bot
SetEnvIfNoCase User-Agent .*nutch.* bad_bot
SetEnvIfNoCase User-Agent .*blexbot.* bad_bot
SetEnvIfNoCase User-Agent .*ezooms.* bad_bot
SetEnvIfNoCase User-Agent .*scoutjet.* bad_bot
SetEnvIfNoCase User-Agent .*majestic-12.* bad_bot
SetEnvIfNoCase User-Agent .*majestic-seo.* bad_bot
SetEnvIfNoCase User-Agent .*dsearch.* bad_bot
SetEnvIfNoCase User-Agent .*blekkobo.* bad_bot
SetEnvIfNoCase User-Agent .*megaindex.* bad_bot
SetEnvIfNoCase User-Agent "WBSearchBot" bad_bot
SetEnvIfNoCase User-Agent "LinkpadBot" bad_bot
SetEnvIfNoCase User-Agent "M---J12bot" bad_bot
SetEnvIfNoCase User-Agent "linkdexbot" bad_bot
SetEnvIfNoCase User-Agent "ltx71" bad_bot
SetEnvIfNoCase User-Agent .*archive.org_bot.* bad_bot
SetEnvIfNoCase User-Agent "IDBot/1\.1" bad_bot
SetEnvIfNoCase User-Agent "SMTBot" bad_bot
SetEnvIfNoCase User-Agent .*a.pr-cy.ru.* bad_bot
SetEnvIfNoCase User-Agent "sukibot_heritrix" bad_bot
SetEnvIfNoCase User-Agent "CheckMarkNetwork" bad_bot
SetEnvIfNoCase User-Agent "Runet-Research-Crawler" bad_bot
SetEnvIfNoCase User-Agent "BackupLand" bad_bot
SetEnvIfNoCase User-Agent "Nimbostratus-Bot" bad_bot
SetEnvIfNoCase User-Agent "Photon/1.0" bad_bot
SetEnvIfNoCase User-Agent "Mb2345Browser" bad_bot
SetEnvIfNoCase User-Agent "LieBaoFast" bad_bot
SetEnvIfNoCase User-Agent "MicroMessenger/6.5.16.1120" bad_bot
SetEnvIfNoCase User-Agent "UCBrowser/11.7.0.953" bad_bot
SetEnvIfNoCase User-Agent "Screaming Frog SEO Spider" bad_bot
SetEnvIfNoCase User-Agent "p---ython-requests" bad_bot
SetEnvIfNoCase User-Agent "Python-urllib" bad_bot
SetEnvIfNoCase User-Agent "C---loudFlare-AlwaysOnline" bad_bot
<Limit GET POST HEAD>
 Order Allow,Deny
 Allow from all
 Deny from env=bad_bot
</Limit>

<IfModule mod_rewrite.c>
# BEGIN Force http to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R=301,L]
# END Force http to https
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.tempdomain\.ga$ [NC]
RewriteRule ^(.*)$ https://tempdomain.ga/$1 [R=301,L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^sitemap\.xml$ wp-content/cache/supercache/tempdomain\.ga/sitemap\.xml
</IfModule>








# code https://www.litespeedtech.com/support/forum/threads/how-to-cut-question-mark-with-htaccess.20759/ - not work
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)\?(.*)$
RewriteRule ^(.*)$ $1\?%1%2 [R=301,L,NE]

RewriteCond %{QUERY_STRING} !=""
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ $1%1? [R=301,L,NE]
</IfModule>











<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /feed [NC,OR]
RewriteCond %{REQUEST_URI} /sitemap [NC,OR]
RewriteCond %{REQUEST_URI} /privacy [NC]
RewriteRule ^(.*[^/])$ $1/ [L,R=301]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^feed/$ wp-content/cache/supercache/tempdomain\.ga/feed/
</IfModule>

#<IfModule mod_rewrite.c>
#RewriteCond %{QUERY_STRING} "_gl=" [NC]
#RewriteRule (.*)  /$1? [R=301,L]
#</IfModule>

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !^/wp-content/cache/
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} !(^|&)_gl=
RewriteCond %{QUERY_STRING} !(^|&)appId=
RewriteCond %{QUERY_STRING} !(^|&)ysclid=
RewriteRule ^(.+?)\.html$ https://%{HTTP_HOST}/$1.html? [L,R=301]

RewriteCond %{REQUEST_URI} !^/wp-content/cache/
RewriteRule ^(.+?)\.html(?!/amp/).+$ https://%{HTTP_HOST}/$1.html? [L,R=301]
</IfModule>

# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible

RewriteCond %{REQUEST_METHOD} !POST
#RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTPS} on
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html" [L]
</IfModule>

# END WPSuperCache
 
Redirect 301 /test.html https://tempdomain.ga/test123.html
 
Options All -Indexes

RedirectMatch 403 ^/stats/.*$

Deny from 5.44.174.37
 

serpent_driver

Well-Known Member
#8
I adviced you to set the new code "on Top" of .htaccess.

Where does the question mark come from? To solve your issue the best solution is to remove the reason why this question mark is set!
 

serpent_driver

Well-Known Member
#10
You have rewrite rules in your .htacess that come from other cache plugins and these rules affects queries in URL, so you have to clean and reset it to default .htaccess. Otherwise there is no way to find a solution. Use Wordpress default .htaccess and remove anything else. If done and if you want to use LiteSpeed cache plugin for Wordpress ask for support at plugin support page at Wordpress. This forum doesn't support it any longer.
https://www.litespeedtech.com/support/forum/threads/please-use-the-official-wordpress-forum.16028/
 
Top