tried several ways to make redirect, but not successfull
Redirect 301 /ru/pages/portfolio/ /ru/pages/portfolio/3/ [END,R=301]
or
Redirect 301 http://myssite/en/pages/portfolio http://myssite/en/pages/portfolio/3
and many others from internet, but all of them not working.
Need to redirect pages/portfolio
to pages/portfolio/3
(for all languages - en, ru)
This is content of file
<IfModule mod_rewrite.c>
# Turn Off mod_dir Redirect For Existing Directories
DirectorySlash Off
# Rewrite For Public Folder
RewriteEngine on
Redirect 301 /ru/pages/portfolio/ /ru/pages/portfolio/3/ [END,R=301]
RewriteCond $1 !^(pma)
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Since you are already using mod_rewrite (for an internal rewrite) you should also use mod_rewrite for this redirect, rather than using a mod_alias Redirect
. Different modules execute at different times during the request, despite the apparent order of the directives in the config file.
However, your example is unclear. The first example includes a trailing slash; the second does not? Is there a trailing slash or not?
Try something like the following instead after the RewriteEngine
directive:
RewriteRule ^(en|ru)/pages/portfolio$ /$1/pages/portfolio/3 [R,L]
This excludes the trailing slash. And assumes "all languages" are just en
and ru
. This is also a temporary (302) redirect. Change to a permanent (301) redirect (if that is the intention) only when you are sure it's working OK, since 301s are cached by the browser. You will need to clear your browser cache before testing.
Redirect 301 /ru/pages/portfolio/ /ru/pages/portfolio/3/ [END,R=301] : Redirect 301 http://myssite/en/pages/portfolio http://myssite/en/pages/portfolio/3
Aside: Neither of these would have worked anyway. End flags like [END,R=301]
are a mod_rewrite syntax, and do not relate to mod_alias (Redirect
). And the URL-path matched by the Redirect
directive should be a root-relative path beginning with a slash, not an absolute URL. See the Apache docs... https://httpd.apache.org/docs/current/mod/mod_alias.html#redirect