Reputation: 101
I am trying to redirect old url to new url but it is not redirecting.
Old url: http://domain.com/STACK/App/ New url: http://domain.com/stack-app
And my .htaccess file Redirect 301 /STACK/App http://domain.com/stack-app
Thanks,
Upvotes: 1
Views: 5775
Reputation: 222
you can use the following code to redirect your website using .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
RewriteRule ^(.*)$ http://www.newexample.com/$1 [L,R=301]
for non www version, you can use the following,
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
RewriteRule ^(.*)$ http://newexample.com/$1 [L,R=301]
Upvotes: 0
Reputation: 785146
You can use this rule as your very first redirect rule in your root .htaccess:
RedirectMatch 301 ^/STACK/App/?$ /stack-app
Upvotes: 1
Reputation: 300
Within the mod_rewrite section of your .htaccess file, add the following lines on the old site:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com\STACK\App\$
RewriteRule (.*)$ http://domain.com/stack-app/$1 [R=301,L]
</IfModule>
Upvotes: 0
Reputation: 309
Try this code.
RewriteEngine on
RewriteRule http://domain.com/STACK/App/ /http://domain.com/stack-app [R=301,L]
For more help go to this link:-- http://edward-designer.com/web/htaccess-url-rewrite-simplified/
Upvotes: 2