0
votes

I'm using a shared linux hosting and have created subdomain which points to /hrms folder inside the root folder.

Now, I've a mod rewrite condition for this subdomain only which goes like this:

RewriteEngine On
RewriteBase /hrms/
RewriteCond %{REQUEST_URI} !^/static/images
RewriteCond %{REQUEST_URI} !^/static/js
RewriteCond %{REQUEST_URI} !^/static/css
RewriteRule ^/(.*)$ /index.php?request=$1 [PT,QSA,L]

But I'm getting this error when I try to login:

http://hrms.atulmy.com/login

Not Found The requested URL /login was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Also, I tried to check if .htaccess is parsed and when I added some junk, the server gave 500 Internal error, so .htaccess is also parsed and is not a problem.

I already searched for same error in google and stackoverflow, but didn't found the mistake I'm doing.

Please help! Thanks...

Atul Yadav. atulmy.com

3

3 Answers

1
votes

I assume that your shared hosting service (SHS) provider provides some subdomain mapper console so the mapping of http://hrms.atulmy.com/ to ~/hrms is done through and SHS-specific RewriteMap in its vhost config.

  1. Verify your assumptions by temporarily renaming .htaccess; dropping a phpinfo script into ~/hrms and doing a http://hrms.atulmy.com/phpinfo.php
  2. Since http://hrms.atulmy.com/login has a REQUEST_URI /login your RewriteBase should be simply / and you should use ~/hrms/.htaccess
  3. You will never match ^/ in an .htaccess rewrite rule.
  4. You should use a relative substitution string in an .htaccess rewrite rule unless you want to rewrite to a different directory hierarchy.
  5. You might want to do a proper redirect of http://atulmy.com/hrms/
  6. You don't want to loop on index.php so you need a guard condition, the easiest way is to use a file existence check which removes the need for the existing static checks .

Giving:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} =atulmy.com
RewriteRule hrms/(.*) http://hrms.atulmy.com/$1     [R=301,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*)               index.php?request=$1 [PT,QSA]

If you don't like this then replace this last condition by:

RewriteCond %{REQUEST_URI} !^/static/(images|js|css)  [OR]
RewriteCond %{REQUEST_URI} !^/index\.php
0
votes

How about this:

RewriteEngine On
RewriteBase /hrms/
RewriteCond %{REQUEST_URI} !^/static/(images|js|css)
RewriteRule (.*) /index.php?request=$1 [PT,QSA]

? Tell me if it works.

0
votes

Can you post more of your Htaccess file? If I try:

http://hrms.atulmy.com/index.php?request=login

It sends me to:

http://hrms.atulmy.com/login