I would like to replace a string from old URL:
http://www.homepage.com/projectname/public/ActionName.action
to
http://www.homepage.com/ActionName.action
or even
http://www.homepage.com/short
I got to this point (trying to it get shorten to http://www.homepage.com/ActionName.action
)
RewriteEngine On
RewriteRule ^/projectname/public/(.*)$ http://www.homepage.com/$1 [R=301,L]
But I get a 404 error:
The requested resource (/projectnameActionName.action) is not available.
I think you're looking for an internal
redirection.
So if you want to be able to put URL's like this in the browser:
http://www.homepage.com/ActionName.action
But show a page like this:
http://www.homepage.com/projectname/public/ActionName.action
Then use this code in your.htaccess.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+) http://www.homepage.com/projetname/public/$1 [NC,L]
Of course replace the domain name and folders to yours.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.