• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Pretty URL .htaccess rewrite subdomain to directory
PostPosted: Wed Sep 25, 2019 5:59 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Mar 24, 2011 12:37 am
Posts: 94
hi guys, i need help figuring out how to .htaccess rewrite subdomain to directory and keep subdomain in url

For example, i need the result of this url:
https://mywebsite.com/reviews/name

to appear like this:
https://reviews.mywebsite.com/name

The content of https://mywebsite.com/reviews/name is generated by LISE and works as expected using the default .htaccess provided by cmsms.

\$1:
<IfModule rewrite_module>

Thanks in advance.

   RewriteEngine on
   # If your CMSMS installation is in a subdirectory of your domain, you need to specify the relative path (from the root of the domain) here.
   # In example: RewriteBase /[subdirectory name]
   RewriteBase /
   
    # +++++ ADD THIS - START +++++
      # Link to http(s)://www.website.com then redirect to https://website.com
      RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
      RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

      # Force URLs have https instead of http
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # ++++++ ADD THIS - END +++++
   
   # Rewrites URLs in the form of /parent/child/grandchild but only rewrites if the requested URL is not a file or directory.
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Pretty URL .htaccess rewrite subdomain to directory
PostPosted: Thu Sep 26, 2019 6:51 am 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3140
Location: The Netherlands
First of all .htaccess rewrite rules are typically used to rewrite request urls, not to generate urls in webpages.

The generation of the url should be done from within the LISE template probably.

I think the rewriting back (from https://reviews.mywebsite.com/name to https://mywebsite.com/reviews/name) may be done within the .htaccess rewrite rules. But probably depends on the configuration of your web environment. If you actually serving the sub domain from a separate folder, you may be able to do it by adding the .htaccess file with proper rules there.
If the subdomain 'points' to the webroot (where CMSMS is installed) you should able to use the .htaccess from that folder to rewrite the url.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Pretty URL .htaccess rewrite subdomain to directory
PostPosted: Thu Sep 26, 2019 7:00 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8170
Location: Fernie British Columbia, Canada
The ,.htaccess file ONLY handles incoming requests, it does not transform URLS the output HTML generated by the web application.

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Pretty URL .htaccess rewrite subdomain to directory
PostPosted: Thu Sep 26, 2019 7:37 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Mar 24, 2011 12:37 am
Posts: 94
I ended up pointing the subdomain to the same folder where the main site is. I then edited the LISE item url to only have:
name
instead of
reviews/name

It works but i need to make sure search engine doesn't see duplicate content.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Pretty URL .htaccess rewrite subdomain to directory
PostPosted: Sat Sep 28, 2019 5:36 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 12674
Location: Arizona
You should be able to add a subdomain in your cPanel which will give you that URL no need for htaccess except maybe for pretty URLs and...

#Sub-dir e.g: /cmsms
RewriteBase /reviews

I how I do all mine...

_________________
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
$1


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: