We have 2 sites on the same niche and basically with the same content, we are going to just close one of them and 301 everything to the one we will be keeping, content is basically the same the only difference is basically the url structure of some pages:
In the one to be 301:
www.domaintobeclosed.com/browse-{keyword}-url string.html
In the one to be redirected to:
www.domaintokeep.com/browse-url string.html
So here the only difference is that in the domain we are keeping the url structure doesnt have the keyword.
The other difference is that in single page url structure:
In the one to be 301:
www.domaintobeclosed.com/title.html
in the one to be redirected to:
www.domaintokeep.com/keyword/title.html
So the difference is that the domain to keep has a keyword before the actual title
Any help on this will be greatly appreciated.
Thanks in advance.
So something like:
RedirectMatch 301 ^/(browse)-keyword-(.*)$ http://www.domaintokeep.com/$1-$2
RedirectMatch 301 ^/([^/])\.html$ http://www.domaintokeep.com/keyword/$1.html
Related
I am trying to change the permalink structure of my Wordpress site and setting up proper redirects. Here is what I am trying to achieve:
Old permalink structure:
/category/post-name
New permalink structure:
/postname
Redirecting would be fairly simply done by:
Source:
/category/(.*)
Destination:
/$1
However, the base URL without the post-name must not be rewritten. So if someone access /category directly (without specifying a post-name) it should not redirect, because /category is a valid page. It should only redirect if something is following /category.
Example:
https://somesite.com/category -> Don't redirect
https://somesite.com/category/post-123 -> redirect URL to https://somesite.com/post-123
Any ideas how I can do this? Note: I am using the Yoast Plugin and its RegEx redirect option.
I am not a coder, so sorry for my gibberish. I hope I am making some sense.
Thank you! :)
Use .+ to match at least one character:
/category/(.+)
I have installed WordPress in in subdirectory.
My url is domain/blog/post-title
now I want domain/pages/post-title
only want change blog with pages, how i can do it in htaccess so all my old url's can 301 redirect on new url?
Thanks
I'm trying to redirect from my old URL structure to a new one where in my case some parameters are added.
The old structure looked like www.url.com/detail/111.html which is rewritten from www.url.com?action=detail&id=111
Now the structure changed for SEO reasons, new the URL for the site mentioned above is something like www.url.com/detail/111/cat/sub.html.
Now i want to redirect from
www.url.com/detail/111.html to
www.url.com/detail/111/cat/xyz.html
or from
www.url.com/detail/112.hmtl to
www.url.com/detail/112/cat/abc.html
The last part in the new URLs is variable!
If im doing it with:
Redirect 301 /detail/112.html http://www.url.com/detail/112.cat/abc.html
the querystring ist added to the new url. The browser shows: http://www.url.com/detail/112.cat/abc.html?action=detail&id=112
When I'm adding a ? to the new URL the ? is also shown in the browser.
QSD doesn't work because Apache 2.2 is running.
Has anyone an idea what to do to solve the problem?
You can put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^detail/112\.html$ http://www.url.com/detail/112.cat/abc.htm? [L,NC,R]
Take note of ? at the end of target URL that is used to strip off any existing query string.
I have a couple of domain extensions that I'd like to redirect to specific pages.
Like example.de has to redirect to example.de/de/ and example.fr to example.fr/fr/.
How can I achieve this? I'm new to regex.
You will edit your .htacess file and put something like to :
RedirectMatch permanent example\.de/$ http://example.de/de
RedirectMatch permanent example\.fr/$ http://example.fr/fr
....
I've made a simple site in Django. The urls I use are http::/www.example.com/nl/ and http://www.example.com/fr/.
My Django urls.py has the following line:
(r'^(?Pnl|fr)/', 'example.views.index'),
In example.views.index I check the language parameter. If it's 'nl' I show a template. If it's 'fr', I show a different template.
This worked great. Now the customer made two different urls:
http://www.dutch.com/ and http://www.french.com/
And finally I'll ask the question:
Is there a way for me to use the new urls without changing my django code? I assume I can tell apache to present the http://www.example.com/nl/ page when the user goes to http://www.dutch.com/. But how do I do this? And will django still be able to get the 'language' parameter from the url?
Thanks in advance for any answers.
If you can use .htaccess files on http://www.dutch.com that you can use apache's redirect directive like so
redirectMatch 301 ^(.*)$ http://www.example.com/nl/
This will redirect all requests sent to dutch.com to example.com/nl
You could also use
redirect 301 /index.html http://www.example.com/nl/
This will redirect only "index.html" on dutch.com to example.com/nl/ (note that the first parameter is a path and can't be an URL - no http://www)