I want to redirect pages from sitename/sitename/pagename.html and sitemap/sitename/ to
sitemap/sitename/pagename
how I can do that by using .htaccess
file
I tried this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule . /sitename/index.php [L]
RedirectMatch 301 (.*)\.html$ sitename/$1
</IfModule>
and I tried also to add
Redirect 301 sitename/sitename/
but it is not working
but I think both not working because it still gives me an error when I open www.sitename/pagename.html
I want to redirect pages from sitename/sitename/pagename.html and sitemap/sitename/ to
sitemap/sitename/pagename
how I can do that by using .htaccess
file
I tried this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule . /sitename/index.php [L]
RedirectMatch 301 (.*)\.html$ sitename/$1
</IfModule>
and I tried also to add
Redirect 301 sitename/sitename/
but it is not working
but I think both not working because it still gives me an error when I open www.sitename/pagename.html
%postname%
is not a mod_rewrite
rewrite tag. You are going to have to write out the path. mod_rewrite
operates before WordPress, or PHP, gets involved. You don't have access to any of that functionality.
If your "contact" page-- the page named "contact"-- has ID 213 you shouldn't have to do anything to redirect, though. This will happen when you enable pretty permalinks.
You can also redirect using WordPress functionality by doing something like:
function redirect_213() {
if (is_page(213)) {
wp_safe_redirect(wp_safe_redirect(home_url('/contact')));
}
}
add_action('template_redirect','redirect_213');
This will probably perform slightly less efficiently than the .htaccess
but you may not notice.