{"id":673,"date":"2016-09-24T03:43:23","date_gmt":"2016-09-24T03:43:23","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=673"},"modified":"2016-09-24T07:44:10","modified_gmt":"2016-09-24T07:44:10","slug":"osclass-sub-domain-setting","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2016\/09\/24\/osclass-sub-domain-setting\/","title":{"rendered":"OSClass Sub Domain Setting"},"content":{"rendered":"<p>First try to install the newest osclass version. Here I use 3.6.1 version. Install it locally. It works! here is the url : http:\/\/localhost\/works\/osclass361. user and password for the admin page (\/oc-admin\/) is &#8216;admin&#8217; and &#8216;admin&#8217;.<\/p>\n<p>Setup the virtualhost<\/p>\n<pre class=\"lang:default decode:true \">sudo gedit \/etc\/apache2\/sites-available\/osclass361.dev.conf<\/pre>\n<p>Here is the content<\/p>\n<pre class=\"lang:default decode:true \">&lt;VirtualHost *:80&gt;\r\n    ServerName osclass361.dev\r\n    ServerAlias www.osclass361.dev\r\n    DocumentRoot \/home\/teddy\/Documents\/works\/osclass361\r\n\r\n    &lt;Directory \/home\/teddy\/Documents\/works\/osclass361&gt;\r\n    AllowOverride All\r\n    Allow from All\r\n    Require all granted\r\n    &lt;\/Directory&gt;\r\n\r\n    ErrorLog \/var\/log\/apache2\/osclass361_error.log\r\n    CustomLog \/var\/log\/apache2\/osclass361_access.log combined\r\n&lt;\/VirtualHost&gt;<\/pre>\n<p>Then enable the website and reload Apache service using below command<\/p>\n<pre class=\"lang:default decode:true\">sudo a2ensite osclass361.dev\r\nsudo service apache2 reload<\/pre>\n<p>Then register the above local site. open<\/p>\n<pre class=\"lang:default decode:true \">sudo gedit \/etc\/hosts<\/pre>\n<p>Then type<\/p>\n<pre class=\"lang:default decode:true \">127.0.0.1   osclass361.dev<\/pre>\n<p>Then restart apache<\/p>\n<p>Then set the permalink for SEF url in the admin page on Show more -&gt; Settings -&gt; permalinks (http:\/\/localhost\/works\/osclass361\/oc-admin\/index.php?page=settings&amp;action=permalinks) then Check &#8216;Enable friendly urls&#8217; then Save Changes! It&#8217;ll create .htaccess file<\/p>\n<pre class=\"lang:default decode:true \">&lt;IfModule mod_rewrite.c&gt;\r\n    RewriteEngine On\r\n    RewriteBase \/works\/osclass361\/\r\n    RewriteRule ^index\\.php$ - [L]\r\n    RewriteCond %{REQUEST_FILENAME} !-f\r\n    RewriteCond %{REQUEST_FILENAME} !-d\r\n    RewriteRule . \/works\/osclass361\/index.php [L]\r\n&lt;\/IfModule&gt;<\/pre>\n<p>Then modify config.php file. Edit these two lines<\/p>\n<pre class=\"lang:default decode:true \">define('REL_WEB_URL', '\/works\/osclass361\/');\r\n\r\ndefine('WEB_PATH', 'http:\/\/localhost\/works\/osclass361\/');<\/pre>\n<p>to<\/p>\n<pre class=\"lang:default decode:true \">define('REL_WEB_URL', '\/');\r\n\r\ndefine('WEB_PATH', 'http:\/\/www.osclass361.dev\/');<\/pre>\n<p>Test the site on your browser: <a href=\"http:\/\/www.osclass361.dev\/\" target=\"_blank\">http:\/\/www.osclass361.dev\/<\/a> or just <a href=\"http:\/\/www.osclass361.dev\/\" target=\"_blank\">osclass361.dev\/<\/a> Here is how it looks\u00a0<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/09\/osclass361.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-676\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/09\/osclass361.jpg\" alt=\"osclass361\" width=\"984\" height=\"399\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/09\/osclass361.jpg 984w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/09\/osclass361-300x122.jpg 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/09\/osclass361-768x311.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a> Because I still have a little listing available, I need to post some of them. NOW it is time to setup the subdomain. I want to use &#8216;City&#8217; as the subdomain based and use wildcard * to make it simpler. From this article <a href=\"https:\/\/dev.osclass.org\/2013\/07\/19\/use-categories-countries-regions-or-cities-as-subdomains\/\" target=\"_blank\">Use categories, countries, regions or cities as subdomains<\/a>, I&#8217;ll follow the guidelines:<br \/>\n1. go to admin Show More -&gt; Settings -&gt; Advanced (http:\/\/www.osclass361.dev\/oc-admin\/index.php?page=settings&amp;action=advanced) then set:<\/p>\n<pre class=\"lang:default decode:true \">Subdomain type: City based\r\nHost: osclass361.dev<\/pre>\n<p>2. Use DNS wildcard<\/p>\n<pre class=\"lang:default decode:true \">sudo gedit \/etc\/hosts<\/pre>\n<p>modify from<\/p>\n<pre class=\"lang:default decode:true \">127.0.0.1   osclass361.dev<\/pre>\n<p>to<\/p>\n<pre class=\"lang:default decode:true\">127.0.0.1   *.osclass361.dev<\/pre>\n<p>3. Modify virtualhost. use *.osclass361.dev instead of www.osclass361.dev on ServerAlias<\/p>\n<pre class=\"lang:default decode:true\">sudo gedit \/etc\/apache2\/sites-available\/osclass361.dev.conf<\/pre>\n<pre class=\"lang:default decode:true\">&lt;VirtualHost *:80&gt;\r\n    ServerName osclass361.dev\r\n    ServerAlias *.osclass361.dev\r\n    DocumentRoot \/home\/teddy\/Documents\/works\/osclass361\r\n\r\n    &lt;Directory \/home\/teddy\/Documents\/works\/osclass361&gt;\r\n    AllowOverride All\r\n    Allow from All\r\n    Require all granted\r\n    &lt;\/Directory&gt;\r\n\r\n    ErrorLog \/var\/log\/apache2\/osclass361_error.log\r\n    CustomLog \/var\/log\/apache2\/osclass361_access.log combined\r\n&lt;\/VirtualHost&gt;<\/pre>\n<p>4. Restart apache<\/p>\n<pre class=\"lang:default decode:true\">sudo service apache2 restart<\/pre>\n<p>5. changes on config.php. Modify from<\/p>\n<pre class=\"lang:default decode:true\">define('WEB_PATH', 'http:\/\/www.osclass361.dev\/');<\/pre>\n<p>to<\/p>\n<pre class=\"lang:default decode:true\">\/\/define('WEB_PATH', 'http:\/\/'.$_SERVER['HTTP_HOST'].'.osclass361.dev\/');--&gt;WRONG!!!\r\ndefine('WEB_PATH', 'http:\/\/'.$_SERVER['HTTP_HOST'].'\/');<\/pre>\n<p>6. Add cookies configuration on config.php<\/p>\n<pre class=\"lang:default decode:true\">define('COOKIE_DOMAIN', '.osclass361.dev');<\/pre>\n<p>7. Modify .htaccess to be like this<\/p>\n<pre class=\"lang:default decode:true \">&lt;IfModule mod_rewrite.c&gt;\r\n    RewriteEngine On\r\n    RewriteBase \/\r\n    RewriteRule ^index\\.php$ - [L]\r\n    RewriteCond %{REQUEST_FILENAME} !-f\r\n    RewriteCond %{REQUEST_FILENAME} !-d\r\n    RewriteRule . \/index.php [L]\r\n&lt;\/IfModule&gt;<\/pre>\n<p>8. Test!<\/p>\n<pre class=\"lang:default decode:true\">http:\/\/www.osclass361.dev\/ --&gt; OK\r\nhttp:\/\/www.osclass361.dev\/oc-admin\/ --&gt; OK<\/pre>\n<p>9. Open the site with the subdomain (city) like: http:\/\/abbeville.osclass361.dev\/<br \/>\nAND IT WORKS!!! IT CAN OPEN THE OTHERS PAGES WITH THE SUBDOMAIN BUT I THINK IT NEED TO BE LIMITED WHICH PAGE CAN BE OPENED BY THE SUBDOMAIN FOR EXAMPLE ONLY FOR ITEMS PAGE AND SHOW THE ITEMS FROM THE CITY!<br \/>\nA FEW ERRORS ENCOUNTER:<\/p>\n<pre class=\"lang:default decode:true \">Internal Server Error\r\n\r\nThe server encountered an internal error or misconfiguration and was unable to complete your request.\r\n\r\nPlease contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.\r\n\r\nMore information about this error may be available in the server error log.<\/pre>\n<p><span style=\"background-color: #ff6600;\">WHEN TRYING TO ACCESS ANOTHER LINK LIKE<\/span> http:\/\/www.osclass361.dev\/user\/login. SO IT ONLY CAN OPEN THE HOMEPAGE!<br \/>\n<span style=\"background-color: #339966;\">SOLUTION<\/span>: It happened because I didn&#8217;t modify .htaccess file, Modify it like #7 above!<br \/>\nIT&#8217;S WORKS NOW BUT SLOW TO OPEN ANYPAGE (WHEN COOKIES IS ALREADY DELETED)!!!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First try to install the newest osclass version. Here I use 3.6.1 version. Install it locally. It works! here is the url : http:\/\/localhost\/works\/osclass361. user and password for the admin page (\/oc-admin\/) is &#8216;admin&#8217; and &#8216;admin&#8217;. Setup the virtualhost sudo gedit \/etc\/apache2\/sites-available\/osclass361.dev.conf Here is the content &lt;VirtualHost *:80&gt; ServerName osclass361.dev ServerAlias www.osclass361.dev DocumentRoot \/home\/teddy\/Documents\/works\/osclass361 &lt;Directory &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2016\/09\/24\/osclass-sub-domain-setting\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;OSClass Sub Domain Setting&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-673","post","type-post","status-publish","format-standard","hentry","category-osclass"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=673"}],"version-history":[{"count":6,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/673\/revisions"}],"predecessor-version":[{"id":683,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/673\/revisions\/683"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}