News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Mod Rewrite

Started by nend, November 27, 2014, 02:34:41 PM

Previous topic - Next topic

nend

Hi,

I have a problem with mod rewrite, I know it has to do with my expression but I was never all that great at that kind of stuff and a little rusty from being away from the coding scene.

Ok, my host has it set up where my main domain is in the root folder. For the sake of tidiness I made a copy of the main domain files to a subfolder. I then did a .htaccess rewrite rule to point that domain to the new folder. All seemed ok and it looked like the sites I often monitor where working right. However this is not the case.

It looks like the rule is rewriting all file operations on the server to point to the folder in the .htaccess which is causing problems with pages that have to load a list of files or do basic file operations.

Here is my rule.
RewriteEngine on
RewriteBase /

RewriteRule ^/?(.*)$ ./_DOMAINS/sicomm.us/_MAIN/$1 [L,QSA]


I just want to rewrite all traffic from domain sicomm.us from the root folder to the new folder. So what is the right rule, I think I am not being too specific with the current rule.

I am going to look into it for now, so lets see who can come up with the fix first. :D

Thanks in advance

nend

I came up with this, it seems to do the job so forth without any file system errors, that I noticed yet.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)sicomm\.us
RewriteRule ^/?(.*)$ ./_DOMAINS/sicomm.us/_MAIN/$1 [L,QSA]


All I did was add a condition on to the existing code.

Would this be ok or is there any better way of doing it for the sake of performance and doing it the right way.

nend

#2
I just noticed one problem, it isn't a problem yet but I noticed this will redirect all from *sicomm.us. In the future I might set up some subdomains what is the correct way to say either from www.sicomm.us or sicomm.us to redirect only.

Thanks

*edit

didn't want to bump this anymore,

How about this for www or non www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.|)sicomm\.us
RewriteRule ^/?(.*)$ ./_DOMAINS/sicomm.us/_MAIN/$1 [L,QSA]

Advertisement: