Last active
February 18, 2016 02:57
-
-
Save zellwk/e222902ecfb555cfcfc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Redirects I hope to achieve: | |
- http://zell-weekeat.com/ -> http://zellwk.com/ | |
- http://zell-weekeat.com/about -> http://zellwk.com/about | |
- http://zell-weekeat.com/about/ -> http://zellwk.com/about | |
- http://zell-weekeat.com/wp-admin/* -> http://zell-weekeat.com/wp-admin/* | |
- http://zell-weekeat.com/wp-content/* -> http://zell-weekeat.com/wp-content/* | |
- http://zell-weekeat.com/* -> http://zellwk.com/blog/* | |
- http://zell-weekeat.com/*/ -> http://zellwk.com/blog/* | |
## Present Condition | |
The present condition is that all urls are routed from zell-weekeat.com/ to zell-weekeat.com /zellwk/ | |
``` | |
- public_html/ | |
|- zellwk/ | |
|- my current files | |
``` | |
The .htaccess is: | |
``` | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^(www.)?zell-weekeat.com$ | |
RewriteCond %{REQUEST_URI} !^/zellwk/ | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ /zellwk/$1 | |
RewriteCond %{HTTP_HOST} ^(www.)?zell-weekeat.com$ | |
``` | |
## What I've tried: | |
``` | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^(www.)?zell-weekeat.com$ | |
RewriteRule about(/)$ http://zellwk.com/about [R=301] | |
RewriteCond %{REQUEST_URI} !^/zellwk/ | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule /wp-admin/(.*) /zellwk/wp-admin/$1 | |
RewriteRule /wp-content/uploads/(.*) /zellwk/wp-content/uploads/$1 [L] | |
RewriteRule ^(.*)$ http://zellwk.com/blog/$1 | |
RewriteCond %{HTTP_HOST} ^(www.)?zell-weekeat.com$ | |
``` | |
URL redirection failled totally. `/about` went to something like `http://zellwk.com/blog/about` or `http://zellwk.com/blog/http:zellwk.com/about`. | |
Any help would be greatly appreciated! |
Here's the solution that worked. Thanks to @simkimsia
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?zell-weekeat.com$
# when whatever comes after zell-weekeat.com/ matches about OR about/
# go to ...
# the L makes sure once this rule matches, stop checking the rest.
# the 301 is for the redirection status code which is good for SEO
# read https://moz.com/learn/seo/redirection
RewriteRule ^about($|/) http://zellwk.com/about [R=301,L]
# when whatever comes after zell-weekeat.com/ AND does NOT match wp-{wildcard here....}
# take that whatever and append to http://zellwk.com/blog/
# and then redirect there using status code 301 and if this rule is true, stop any further
RewriteRule !^(wp\-.*) http://zellwk.com/blog%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} !^/zellwk/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /zellwk/$1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this:
Also a note: If someone goes to
http://zell-weekeat.com/blog/hi/
, it’ll redirect tohttp://zellwk.com/blog/blog/hi/
so to account for that, make sure to set rewrite rules onzellwk.com
as well.