RewriteRule ^([^/\.]+)/$ $1 [R]
redirects from website.com/abc/
to website.com/home/user/www/abc
How do I redirect to the correct location? (website.com/abc
)
RewriteRule ^([^/\.]+)/$ $1 [R]
redirects from website.com/abc/
to website.com/home/user/www/abc
How do I redirect to the correct location? (website.com/abc
)
The first part of the RewriteRule
is the matching part, the second the replacement expression. For full-url RewriteRule
s they should start with a ^/
(slash), because a path after http://exampl.com
always starts with the root-slash. To redirect http://example.com/abc/
to http://example.com/abc
(remove the trailing slash) you can do this:
RewriteEngine On
RewriteRule ^/([^/]+/$ /$1 [R]
It looks like the URL is already being rewritten to a filename and then you are rewriting the filename. This usually happens when the rewrite rule is being specified in an .htaccess file. The problem is due to the fact that by the time Apache reads the .htaccess file, it has already resolved all URLs to filenames. The standard solution to this is to supply a RewriteBase rule in your .htaccess. Try:
RewriteBase /
Above your RewriteRule for starters.
More documentation is here
You could try it with the additional L flag to avoid any further rules to be applied:
RewriteRule ^([^/\.]+)/$ /$1 [R,L]
But if nothing else works, try this:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ (/[^/.?\ ]+)/[? ]
RewriteRule ^[^/.]+/$ %1 [R]