For .htaccess file, with ISAPI_rewrite
I'm designer not coder, need help if someone can code for rewrite urls for SEO - Thanks in advance.
I have multiple domains on same server and each domain's content is sharing folders:
(www.)domain1.com/
(www.)domain2.com/
all should rewrite and url show http(s)://www.maindomain1.com
and content is from root/sitefolder1/index.php
and same for other pages like:
(www.)domain1.com/about.php
(www.)domain2.com/about.php
should rewrite and url show http(s)://www.maindomain1.com/about.php
and content is from root/sitefolder1/about.php
but contact page need to rewrite like:
(www.)domain1.com/contact/person-name1
(www.)domain2.com/contact/person-name1
should rewrite and url show http(s)://www.maindomain1.com/contact/person-name1
and content is from root/sitefolder1/contact.php?p=person-name1
and for blog I am using wordpress so need rewrite for that too,
I am using permalinks option "Post name http://www.example.com/sample-post/"
(www.)domain1.com/blog
(www.)domain2.com/blog
should rewrite and url show http(s)://www.maindomain1.com/blog
and content from root/sitefolder1/blog/ (not sure, what page wordpress use)
(www.)domain1.com/blog/post1
(www.)domain2.com/blog/post1
should rewrite and url show http(s)://www.maindomain1.com/blog/post1
and content from root/sitefolder1/blog/ (not sure, what page wordpress use)
(www.)domain1.com/blog/category/post2
(www.)domain2.com/blog/category/post2
should rewrite and url show http(s)://www.maindomain1.com/blog/category/post2
and content from root/sitefolder1/blog/ (not sure, what page or folder wordpress use)
and same process for other domains as domain1 and doamin2 like:
(www.)domain3.com
(www.)domain4.com
all should rewrite and url show http(s)://www.maindomain2.com
and content from root/sitefolder2/index.php
The starting point for you can be helicontech.com. Start with FAQ - http://www.helicontech.com/forum/10648-FAQ.html, move to Examples Section - http://www.helicontech.com/isapi_rewrite/doc/examples.htm. There you'll find the first couple rules to redirect domains. In order to use WP - read http://www.helicontech.com/articles/isapi-rewrite-with-wordpress/
Related
I got a website running and in the subdirectory domain.com/blog/ I installed a Wordpress blog website. The subdirectory contains dozen of blog articles, for example
domain .com/blog/testing
domain .com/blog/example
domain .com/blog/article1
domain .com/blog/article2
And what I am trying to do is to rewrite and redirect (a single page) domain.com/blog/example to domain.com/example
Any way to do this?
It seems javascript redirect is better than htaccess redirect for your case.
Simply edit your article using a code editor in wordpress.
<script>window.location = "http://www.yourhomepage.com";</script>
i have a wordpress site let just call it testing.com
with a page url called blog/ which can access via testing.com/blog
i am using NGINX as the web server.
How do i rewrite the testing.com/blog to blog.testing.com with all its content still intact?
//edit
in this case, /blog is a page in the wordpress and not the wordpress itself, only that page and all the link inside the page would be rewrite to the subdomain and nothing else
example:
inside of the blog.testing.com there was 2 more link such as:
1. older post
(original link will be testing.com/blog/page/2 and change it to blog.testing.com/page/2)
1. read more on each post
(original link will be testing.com/2017/05/testpost1 and change it to blog.testing.com/2017/05/testpost1)
//end of edit
so as to say as if i am opening testing.com/blog in blog.testing.com
i have tried rewrite and proxy pass
location ^~ /blog/ {
rewrite ^/admin(.*) http://blog.testing.com$uri permanent;
}
with the above block
the result is same as return the url only and not with the supposed content.
or is it not possible to do so?
Hi assuming that you don't want to keep the URL testing.com/blog at all and instead want to use the subdomain blog.testing.com then effectively what you want to achieve is a WordPress migration. There are a number of ways you can achieve a migration, depending on how technically able you are. The easiest way is probably to install and use a WordPress migration plug in such as WordPress Duplicator or WordPress Move. Please take a backup of your files AND database before you start.
The official WordPress guide to migration can be found at https://codex.wordpress.org/Moving_WordPress
In short you would create the subdomain, then move (migrate) the site that's currently at testing.com/blog to the subdomain blog.testing.com
If the subdomain directory is to be left at /blog and you are just pointing the subdomain to that directory, then you might be able to do what you need to do just by updating the database to reset all the internal URLs in the WordPress database. In this case you could consider using https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
This is what I tend to use when migrating sites from test to live. Hope this helps.
until I added the string: remove_filter('template_redirect', 'redirect_canonical'); to functions.php of current theme the site even did not load in browser. Now it loads ok, but when I checked site load with tools.pingdom I saw dozens of those "Remove the following redirect chain if possible" errors. Each of them is the same error about some image:
Remove the following redirect chain if possible:
http://www.domain.com/wp-content/thumbs/fgd/0-9/10-bullets.png
http://domain.com/wp-content/thumbs/fgd/0-9/10-bullets.png
etc. about 200 of the same kind.
It is a game arcade plugin and those are paths to thumbnails of games. Could you point me where to dig?
Ok, it seems that you have (or used to have) your wordpress site configured at the url www.domain.com
This means that any images you pasted on your posts began with www.domain.com.
It's possible that images on your theme are also hard linked to www.domain.com too.
Your nginx vhost has these rules
server_name www.domain.com domain.com;
if ($host != 'domain.com') {
rewrite ^/(.*) http://domain.com/$1 permanent;
}
Which mean "listen to either www.domain.com or domain.com, but force whoever request the www domain to perform another request in order to end up at domain.com."
This is meant to canonicalize your site url and avoid google indexing your content twice, which would split pagerank and authority and probably downrate it as duplicate content.
The problem is that this rule operates on the images you already have linked ar www.domain.com, so everytime you request them, nginx redirects you.
TL/DR
Make sure the url you have configured at your wordpress installation matches the one you're enforcing in your nginx vhost. If you want to strip the www part, fine, but do it in both parts.
Second: for the images on your theme, you'll have to manually edit the urls to get rid of the www. You can also use relative links
<img src="/wp-content/thumbs/fgd/0-9/10-bullets.png">
instead of
<img src="http://domain.com/wp-content/thumbs/fgd/0-9/10-bullets.png">
Third: do the same check for the posts you have published until now.
I have a WordPress website where the requirement is exactly like below:
WordPress site should be installed on: http://www.mydomain.com/wp/ |
Website homepage should be access from: http://www.mydomain.com/ if someone visits http://www.mydomain.com/wp/ he should be redirect to http://www.mydomain.com/
But when accessing all other inner pages, visitors should follow the URL format:
http://www.mydomain.com/wp/test-page1
http://www.mydomain.com/wp/test-page1
This means I need the main website access from main domain directly but all other inner pages should open under sub-directory as mentioned above.
how can I do that with .htaccess? Thanks
Please look into this website about htaccess redirects: http://htaccess.wordpress.com/2008/09/15/redirecting-urls-in-htaccess/
Aside from that, you will want to have your RewriteBase to be / and not wp so that the user doesn't go to wp subfolder automatically.
I have magento on my root domain with wordpress integration, so currently I have url like www.myurl.com/blog and I don't to display /blog in my url. the result url should be www.myurl.com/
is there a way to do this?
You need to go to settings>general and change the site url to www.myurl.com and the wordpress url to www.myurl.com/blog then COPY not move the .htacess and index.php files into the root directory. This should use wordpress as the site for the domain now. In order to access the backend you will still need to go to www.myurl.com/blog/wp-admin