Hi I have wordpress installation in subfolder /blog/, as it has to co-exist with other legacy cms, so now if i wish to access some page of wordpress i need to use links as
www.domain.com/blog/news/ and would like to rather use www.domain.com/news/.
So basically for certain links i need to add this /blog/ somehow internally so wordpress
would handle it normally.
Please note it will be few links so rewrite rules can be literal.
Rewriting URI's for wordpress can always be kind of sketchy because wordpress has its own way to do routing and may not play nicely with other rewriting sometimes, but you can try:
RewriteRule ^/?news/some-page$ /blog/news/some-page [L]
As long as they're before any other wordpress related rules.
Related
I'm currently using a complex multisite setup. I have the site as the landing page/blog and another site for the main functionality. The subdomain of the main site is set to /dashboard/ so every other page that loads after has the dashboard slug in it. IE www.name.com/dashboard/post-a-project.
Is there was a way to make the website appear as www.name.com/post-a-project while not interfering with the landing page site? This is mostly for aesthetic purposes.
Try and use this in your .htaccess file:
RewriteEngine On
RewriteRule ^dashboard/(.*)$ /$1 [L,R=302]
I've set it to a temporary redirect using R=302. If this works for you then change it to R=301 to make it a permanent redirect.
Make sure you clear your cache before testing this.
I'm trying to add some rewrite rules to a Wordpress site, to go a little further than wp's own rewrite capabilities, but i am having trouble when I place those rules BEFORE wordpress own rules: if my rule rewrites to something that wordpress will rewrite later, it doesn't work. E.g:
www.domain.com/hello -> www.domain.com/image.jpg : this works, as wordpress doesn't interfere
www.domain.com/hello -> www.domain.com/category/1 : doesn't work, even if www.domain.com/category/1 works by itself
I've tried to remove the L tag from my rewrite rules, to allow further rewriting, but it doesn't seem to work...maybe wordpress does starnge things with htaccess?
Does this sound familiar to anyone?
Thank you
Wordpress doesn't check the rewritten url (/category/1), but parses the original request url (/hello), and so it doesn't know what to do with /hello. To fix this use the proxy flag. So [L] would become [L,P]
I want to move Wordpress to another domain and also change the permalinks. So basically what I want is to move from: oldsite.com/PostId-PostName.html to newsite.com/PostName/
I know this can be done from .htaccess, but I don't manage to get it right. Can you please help me ?
This is how it can be done using Apache's mod_rewrite:
# Activate Rewrite Engine
RewriteEngine On
# redirect posts to new site
RewriteRule ^(\d+)-([^/]+)\.html http://www.newsite.com/$2/ [R=301,NC,QSA,L]
This will ONLY redirect URLs like oldsite.com/12345-very-interesting-post.html.
There is a Codex article dedicated to this: Moving WordPress
I have a website and want to redirect all its pages to posts on my blog. I browsed through my website folder but could not find the '.htaccess' file. Is it provided by the web hosting or can I create my own and use it? Can it be only used with Apache server.
If that's not possible what other option do I have for redirection.
Janice
You create your own .htaccess, by simply opening a document and saving it as .htaccess.
You'll want something like this in it:
RewriteEngine on
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Perhaps you just don't see the .htacces file. The dot at the beginning of the file name indicates that this is a hidden file and will not be displayed normally.
If you don't want to mess around with editing your .htaccess file, Redirection is a good Wordpress plugin that handles 301 redirects, logs, etc. and is easy to use.
.htaccess is for Apache only, other web servers have their own methods of configuration and do not use .htaccess files.
Since this is tagged "Wordpress" maybe you are using that? Wordpress will create one after you've turn on pretty permalinks.
Any recommendations or best practices for mapping a subdomain to a Wordpress page:
http://my-page.mydomain.com -> http://mydomain.com/my-page
I don't want to do a redirect either, just keep the original subdomain URL until a different link is click, and then the subdomain is removed.
I'm using Apache 2 with mod_rewrite, wordpress 2.7 with pretty-urls, and php 5.
As already mentioned I would use mod_rewrite to get this done. Something like the following should work in the my-page.mydomain.com virtual host
RewriteEngine on
RewriteRule (.*) http://mydomain.com/my-page$1 [P,L]
This will require you to enable mod_proxy. Please read the security implications of doing this on the Apache website http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
URL Rewriting. I would start here
What you want can be achieved with mod_rewrite.
Keep in mind that google will detect the two pages as duplicates, which may hurt your pagerank.