Forum Moderators: phranque
Im trying to do some URL re-writing with Apache's mod_rewrite. However, I can't get it to work.
Whenever I type in the 'fake' URL I get a '404 not found' error rather than it redirecting the URL
to where I have specified in .htaccess.
As you will see from my .htaccess file below, im trying to do the following redirection.
If a user types in [mysite.com.au...] I want them to be redirected to
[mysite.com.au...]
What have I done wrong? I got my ISP webmaster to restart Apache but it still doesn't work.
The .htaccess file is in the root directory and I have uncommented the 'RewriteEngine On' as
shown below.
My .htaccess file:
# -FrontPage-
#Redirect https://www.mysite.com.au
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
#Options ExecCGI FollowSymLinks
RewriteEngine On
RewriteRule ^/shop/category/Book/$ /cgi-bin/shoppingcart/product.cgi?category=Book
RewriteRule ^/shop/category/Video/$ /cgi-bin/shoppingcart/product.cgi?category=Video
RewriteRule ^/shop/category/Stationery/$ /cgi-bin/shoppingcart/product.cgi?category=Stationery
RewriteRule ^/shop/category/Equipment/$ /cgi-bin/shoppingcart/product.cgi?category=Equipment
RewriteRule ^/shop/category/Other/$ /cgi-bin/shoppingcart/product.cgi?category=Other
RewriteRule ^/shop/category/Tool/$ /cgi-bin/shoppingcart/product.cgi?category=Tool
## IF the port is 80 (ie http)
#RewriteCond %{SERVER_PORT} ^80$
## THEN externally redirect (ie 30x) index.php to the https server
#RewriteRule (.*)$ https://%{HTTP_HOST}/$1 [L,R]
##RewriteRule ^index\.shtml$ https://%{HTTP_HOST}/index.shtml [L,R]
AuthName vweb11.myhost.com.au
AuthUserFile /webhome2/www.mysite.com.au/_vti_pvt/service.pwd
AuthGroupFile /webhome2/www.mysite.com.au/_vti_pvt/service.grp
ErrorDocument 401 /401.html
Error log:
[Tue Jan 31 17:26:28 2006] [error] [client myipaddress] File does not exist: /webhome/www.mysite.com.au/shop/category/Video/
RewriteRule ^shop/category/(Book¦Video¦Stationery¦Equipment¦Other¦Tool)/?$ /cgi-bin/shoppingcart/product.cgi?category=$1 [L]
Change the broken vertical pipe "¦" to a solid pipe before use: Posting on this board modifies that character.
You will want to do the external redirect to https before doing this rewrite, otherwise your script URL will be 'exposed' to users and SE robots. Use a 301 redirect [R=301] to avoid search engine's 302-handling problems.
Jim