[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Problem with the rewrite rule

Hello,

I have a following rule in the .htaccess file

RewriteEngine on
RewriteRule ^home$ main.php?mainID=1

main.php file is located in public/OKD/ folder, and .htaccess file is located in the same folder.

When I go to somewebsite.com/OKD/home I get the following error:

Not Found
The requested URL /s/o/somewebsite.com/public/OKD/main.php was not found on this server.

Any idea why this would be happening?

Thanks,
Dragan
0
cP6uH
Asked:
cP6uH
  • 10
  • 9
2 Solutions
 
farzanjCommented:
You rewriteRule appears wrong.  Could you tell me what you want to redirect to where?
0
 
cP6uHAuthor Commented:
What I want to do is when you go to somewebsite.com/OKD/home, I want it to redirect to http://somewebsite.com/OKD/main.php?mainID=1.
0
 
farzanjCommented:
In you Apache config file (httpd.conf or apache.conf), use this redirection

Redirect /home http://somewebsite.com/OKD/main.php?mainID=1

Restart apache service

Any issues?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
farzanjCommented:
Sorry, I mixed up this one with another one.  Please hang on
0
 
farzanjCommented:
RewriteRule /home main.php?mainID=1
0
 
cP6uHAuthor Commented:
Different error now...
The requested URL /OKD/home was not found on this server.
0
 
farzanjCommented:
Sorry, my fault.  This should work. If it doesn't, I would put more conditions in
RewriteRule /home http://somewebsite.com/OKD/main.php?mainID=1
0
 
cP6uHAuthor Commented:
Yes, I know that works, but doing it that way, in the address bar, the http://somewebsite.com/OKD/main.php?mainID=1 shows then. I want it to show http://somewebsite.com/OKD/home.
0
 
farzanjCommented:
Ok, try this one:
RewriteBase /
RewriteRule /home /OKD/main.php?mainID=1 [R,L]

0
 
cP6uHAuthor Commented:
Nope... The requested URL /OKD/home was not found on this server.
0
 
farzanjCommented:
Lets try this one
RewriteRule ^(/home)$ /OKD/main.php?mainID=1 [R,L]
0
 
cP6uHAuthor Commented:
Still the same. The requested URL /OKD/home was not found on this server.
0
 
farzanjCommented:
Ok.  Please give complete path.

cd OKD
pwd

Put the complete path

RewriteRule ^(/home)$ /complete/path/OKD/main.php?mainID=1 [R,L]
0
 
cP6uHAuthor Commented:
OKD is located in the public folder, so the complete path is /public/OKD/OKD/main.php?mainID=1.

This didn't work either.

When I tried the following:
RewriteRule ^(home)$ /OKD/main.php?mainID=1 [R,L]

It took me to the http://somewebsite.com/OKD/main.php?mainID=1 and it showed the page correctly, but at the same time it showed the  http://somewebsite.com/OKD/main.php?mainID=1 in the address bar instead of  http://somewebsite.com/home.
0
 
cP6uHAuthor Commented:
All right, I got it working...

The correct line is

RewriteEngine on
RewriteRule ^home$ /OKD/main.php?mainID=1

Thanks a lot for your help!
0
 
farzanjCommented:
I am glad it worked.  So I was just a slash off.  /home instead of home
0
 
cP6uHAuthor Commented:
Yes, but also the  [R,L] at the end had to go too.
0
 
farzanjCommented:
Yes, I have been putting [R,L].  Anyway thanks for points.
0
 
cP6uHAuthor Commented:
farzanj helped me get to the solution, but none of his answers were completely correct.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now