0

I was using a plugin called wordpress subdomains 0.6.9 but it has lots of bugs and creating subdomains with this version is risky, I mean later there will be lots of broken links, so is there any way to do this manually, by editing the php code or database values ? or anything else that will make this work ? and thank you :D

Peter
  • 185
  • 4
  • 7

2 Answers2

2

Just an idea: create a wildcard subdomain within your apache config (assuming you´re using apache webserver) and let it point to a php script which redirects acording to the given subdomain.

Tobias
  • 7,238
  • 10
  • 46
  • 77
  • That is interesting - but how would such a script work ? what would it check for ? – Obmerk Kronen May 04 '15 at 18:54
  • Compare to this post: https://stackoverflow.com/questions/18539141/how-do-i-get-htaccess-to-redirect-from-wildcard-subdomain-page-to-wildcard-subd – Tobias May 05 '15 at 06:46
  • The redirect is understood and easy.. the php script part was my comment subject.. – Obmerk Kronen May 08 '15 at 03:47
  • 1
    The script would extract the called URL from the HTTP request, you can parse this URL then and do whatever you like to do :) See https://stackoverflow.com/questions/5292937/php-function-to-get-the-subdomain-of-a-url – Tobias May 11 '15 at 07:06
2

Are you using Apache2 + permalink? If so, craft some RewriteRule within .htaccess could do it (along with the original permalink).

For example

RewriteCond %{HTTP_HOST} cat1.my.site
RewriteRule ^.*$ /categories/cat1$0 [R]

Or, do 301 redirection

RewriteCond %{HTTP_HOST} cat1.my.site
RewriteRule ^.*$ http://my.site/categories/cat1$0 [R,L]

(Above code is untested so you might want to compare them with doc and test)

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

timdream
  • 5,914
  • 5
  • 21
  • 24