简体   繁体   中英

.htaccess mod_rewrite rule not working in Ubuntu

My apologies if this is an easy one. I have Googled it up the hizzy to no avail.

I am running Ubuntu 9.04, Jaunty Jackelope and Apache2. After much trouble, I finally enabled mod_rewrite, and my .htaccess file is attempting to do it's thing, but is failing. This is my setup.

In /etc/apache2/conf.d/ I have a file called apeace-public-html.conf. It reads as follows:

# makes /home/apeace/public_html/ available through /localhost/apeace

Alias /apeace /home/apeace/public_html/

And in /home/apeace/public_html/ I have the following .htaccess file:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^test\.html$ index.html

Also in /home/apeace/public_html/ I have a file named index.html, but I do NOT have a file named test.html. It seems to me that this rewrite should show index.html when I try to access http://localhost/apeace/test.html . However, this is the error I get:

Not Found

The requested URL /home/apeace/public_html/index.html was not found on this server.

So the question is, what in the world am I doing wrong?

Much thanks.

-apeace

Just a guess here, but can you try to make the RewriteRule like ^test.html$ /apeace/index.html

From the error message, it seems it is translating ` http://localhost/apeace/test.html to http://localhost/home/apeace/public_html/index.html

Your rewrite rule is working correctly since it's telling you it can't find "index.html". If you went to test.html and it said it can't find "test.html" then your rewrite rule would be at fault.

So what this means is that something else is wrong in your setup, whether it's a bad file or directory name somewhere, or whatever else. Make sure there's nothing basic you're overlooking.

But in answer to your question (especially the title), your htaccess is fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM