To remove multiple slashes I wrote this condition that is working in windows system but not in Ubuntu 18.04 I don’t know why..?
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{THE_REQUEST} ^[A-Z]+s//+(.*)sHTTP/[0-9.]+$
RewriteRule .* %{HTTP_HOST}/%1 [R=301,L]
I am getting this error in ubuntu system..
Forbidden
You don’t have permission to access this resource.
And my URL changed this
http://in.decashop.localhost/p/8489882_500-boys-gym-short-sleeved-t-shirt-grey.html
to this
http://in.decashop.localhost/var/www/html/decashopglobal/www/in.decashop.localhost/p/8489882_500-boys-gym-short-sleeved-t-shirt-grey.html
if I put multiple slashes like
http://in.decashop.localhost///p/8489882_500-boys-gym-short-sleeved-t-shirt-grey.html
3
Answers
This Rule worked for me..
Thanks To All.
At first, you can check apache’s log. try to access your website using URL or IP and check your Webserver’s log information.
In ubuntu you can try:
In most cases wrong permission is the main cause of this problem.
The output you are seeing is consistent with the directives you have posted, as you are missing the scheme (ie.
http
) on the substitution string in theRewriteRule
directive (which presumably should be an absolute URL) – so I don’t see how this would have “worked” on the Windows server? Unless you had a very different config (but even then it couldn’t have worked the same way).With the
RewriteRule
directive as written, the substitution string (ie.%{HTTP_HOST}/%1
) would be seen as a relative URL and Apache would then add back the directory-prefix ie./var/www/html/decashopglobal/www/
prior to issueing the redirect – which naturally results in the malformed redirect you are seeing. If you had set aRewriteBase
directive elsewhere in the config file, then this would have overridden this behaviour (although still wouldn’t have produced the output you seem to be expecting).Also note that these directives are intended to remove multiple slashes from the start of the URL-path only, not elsewhere in the URL-path.
So, you would need to change the
RewriteRule
directive to read:OR, remove the
HTTP_HOST
server variable altogether (to make the substitution string root-relative):You will need to clear your browser cache before testing, as the erroneosu 301 (permanent) redirects will be cached persistently by the browser. (Test with 302s to avoid caching issues in the future.)