Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite on WampServer (localhost)

         

recycle_bin

3:49 pm on May 19, 2008 (gmt 0)

10+ Year Member



hi all,
I have some troubles with rewriting URLs in my local PC, and I hope you can help me! (thanks)

machine details:
OS: win xp pro SP2
Server: WampServer 2.0c (apache 2.2.8)

rewirte goal:
simple test redirection (foo.html to bar.php)

problem:
after redirection, apache point to the document root (c:/wamp/www/) for destination page (not in alias directory)

apache alias.conf:

Alias /sample/ 'd:/web/sample.com/www/' 

<Directory 'd:/web/sample.com/www/' >

 Options Indexes FollowSymLinks MultiViews

 AllowOverride all

 Order allow,deny

 Allow from all

</Directory>

.htaccess file:

Options -Indexes -MultiViews

RewriteEngine On

RewriteBase /

RewriteRule ^foo.html$ /bar.php [NC,L]

rewrite.log:

strip per-dir prefix: d:/web/sample.com/www/foo.html -> foo.html

applying pattern '^foo.html$' to uri 'foo.html'

rewrite 'foo.html' -> '/bar.php'

trying to replace prefix d:/web/sample.com/www/ with /

internal redirect with /bar.php [INTERNAL REDIRECT]

Apache_error.log:

script 'C:/wamp/www/bar.php' not found or unable to stat

I’m trying every thing that find in search engine and technical forums. Also I changed the RewriteBase and Flag(s) for many times, but any solutions not worked.

.htaccess options (such as –MultiViews) was changed and I test the RewriteRule like below (without backslash befor bar.php and NC flag) :

RewriteRule ^foo.html$ bar.php [L]

When backslash removed

rewrite.log:

strip per-dir prefix: d:/web/sample.com/www/foo.html -> foo.html

applying pattern '^foo.html$' to uri 'foo.html'

rewrite 'foo.html' -> '/bar.php

Apache_error.log:

Invalid URI in request GET /sample/foo.html HTTP/1.1

Any help appreciated,
thanks

jdMorgan

6:07 pm on May 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry -- In a bit of a rush, but see the [PT] flag for rewriterule. It will likely be needed if you wish to pass the output of mod_rewrite through mod_alias.

Jim

recycle_bin

8:06 am on May 20, 2008 (gmt 0)

10+ Year Member



Dear jim, thanks for your help.

After I copy my project files in a “test” folder in “c:/wamp/www/” and change RewriteBase to “/test/” rewrite rules work perfectly but I decide to switch a *nix like environment for development (matching local machine and remote server).

thanks again for your reply :-*