logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: File .htaccess
Author
MCruz



Joined: 31 Jul 2015
Posts: 3

PostPosted: Fri 31 Jul '15 18:27    Post subject: File .htaccess Reply with quote

Hi to all,

I have the following folder structure (/sites/test and /login inside www-root/):

Quote:
www-root
/sites/test ->Frontend
/login -> Backend


With this rule:
Code:
RewriteRule %{REQUEST_URI} !(.*)sites/test
RewriteRule ^(.*)$ sites/test/$1 [L]

that I put on .htaccess, when I put in my browser www.mywebsites.com I access directly to the folder /sites/test and I can see the index.html page inside.
The problem is that I can not longer access to the folder /login no more. I put www.mywebsites.com/login and gives nothing.

Can someone tell me what rule I have to put to access also to /login?

To work like this:
www.mywebsites.com -> redirects to -> www.mywebsites.com/sites/test
www.mywebsites.com/login -> redirects to -> www.mywebsites.com/login

Thanks
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Mon 03 Aug '15 16:46    Post subject: Reply with quote

You have to exclude the login folder, cause rewrite everything with ^(.*)$

Code:

RewriteRule ^(sites/test|login) - [L]
RewriteRule ^(.*)$ sites/test/$1 [L]
Back to top
MCruz



Joined: 31 Jul 2015
Posts: 3

PostPosted: Mon 03 Aug '15 17:56    Post subject: Reply with quote

Hi,

thanks a lot for the tip.

I have test with that two rules and putting www.mywebsites.com it redirects to www.mywebsites.com/sites/test

but putting www.mywebsites.com/login it gives:
Not Found
The requested URL /login was not found on this server.

Thanks
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Mon 03 Aug '15 21:07    Post subject: Reply with quote

Then there must be a rule to rewrite all urls. Are that all rewrite rules?

Or can you open /login/somefile.ext ? Like /login/index.php ?
Back to top
MCruz



Joined: 31 Jul 2015
Posts: 3

PostPosted: Tue 04 Aug '15 10:19    Post subject: Reply with quote

Hi,

I have tried with the two rules bellow, individualy and both at the same time:
Code:
RewriteRule ^(sites/test|login) - [L]
RewriteRule ^(.*)$ sites/test/$1 [L]

Code:
RewriteRule %{REQUEST_URI} !(.*)sites/test
RewriteRule ^(.*)$ sites/test/$1 [L]


Without the two rules I can access to /sites/test/index.html puting www.mywebsites.com/sites/test and I can acccess to /login/index.html using www.mywebsites.com/login.

What I'm trying to do is to hide the /sites/test/ from the url, so we can do only www.mywebsites.com and redirects to www.mywebsites.com/sites/test. The second rule above do this but at same time block the access to www.mywebsites.com/login. And block because when I do this www.mywebsites.com/login on browser, what the rule seems to really do is www.mywebsites.com/sites/test/login. Of course inside /sites/test do no exist login.

thanks again.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Wed 05 Aug '15 18:00    Post subject: Reply with quote

You may try
Code:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/login(.*)$
RewriteCond %{REQUEST_URI} !^/sites/test(.*)$
RewriteRule ^(.*)$ /sites/test/$1
Back to top


Reply to topic   Topic: File .htaccess View previous topic :: View next topic
Post new topic   Forum Index -> Apache