Jump to content
The Uniform Server Community
Sign in to follow this  
mbenam

mod_rewrite problem

Recommended Posts

Hello,

 

I am trying to check whether mod_rewrite is working on my installation or not. I have ensured that mod_rewrite is not commented out in the http.conf at \usr\local\apache2\conf. At docroot I have two files test.html and test2.html. I tried to access http://localhost/test.html using the following .htaccess file and get a 403 forbidden error.

 

Order Deny,Allow

Deny from all

Allow from 127.0.0.1

 

RewriteEngine On

RewriteRule ^test.html$ /test2.html [R=301]

 

If I delete the first 3 lines then I get a 500 Internal Server Error.

 

Can anyone please help me out here?

 

Thanks.

 

mbenam.

Share this post


Link to post
Share on other sites

If you are trying to access your server from "localhost" or "127.0.0.1" then you should not get a Forbidden error. If you are access it via your IP then you should.

 

About the 500 internal error, i do not think you use mod_rewrite like that. You use it like that for a PHP script but not for HTML i think.

 

Anyways, try a PHP script like MediaWiki and test it to see if it will work...

Share this post


Link to post
Share on other sites

Hi,

 

I have been trying to access the page using localhost and still getting the forbidden error. Also I tried changing the file extension from .html to .php. I am getting the same error. Can you explain your comment about PHP script like Mediawiki.

 

Thanks.

 

mbenam.

Share this post


Link to post
Share on other sites

You can't just change the extention. Everything depends on what is the file for the mod_rewrite to work. :D Search Google for a sample script, tutorial or something and test it.

 

About the forbidden error, you should not be getting that. It restricts access to your server to only localhost, meaning those outside can't access it. Change it from 127.0.0.1 to localhost and see what happens. :D

Share this post


Link to post
Share on other sites

try putting this in the .htaccess file

REDIRECT from to

where "from" is the server path (I think relative to the .htaccess file) of the file or directory (with a slash at the end) that you are redirecting from and "to" is the full url of the page to redirect to.

Share this post


Link to post
Share on other sites

Hello everyone,

 

the CMS I am using suggested to add this line in .htaccess and that did the trick.

 

Options +FollowSymLinks

 

I am not sure what it's doing but it's working perfectly. I guess I have to study more about mod_rewrite.

 

Thanks.

 

mbenam.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...